Pin4 is usually PORTB.4, and not actually Pin4 on the chip.
Which chip are you using?
<br>
Pin4 is usually PORTB.4, and not actually Pin4 on the chip.
Which chip are you using?
<br>
DT
I'm using a 12F683, GP4 (which I believe is the same as PORTB.4?) is Pin3.
www.theLanguageBear.com - Multi-Lingual books for kids and adults of all skill levels.
I could use some help here... I am completely at a loss. I can't get any input to work at all, am I going crazy?
www.theLanguageBear.com - Multi-Lingual books for kids and adults of all skill levels.
For a 12F683, you need to turn off the Analog inputs and Comparator.
SYMBOL ANSEL = $9F
SYMBOL CMCON0 = $19
POKE ANSEL, 0
POKE CMCON0, 7
hth,
DT
I cannot express enough gratitude. It works! Thank you so much kind sir. Now where might one learn a bit of information like that? That seems fairly basic, but I don't recall coming across that in any of my "pic'n" books or the 12F datasheet...
www.theLanguageBear.com - Multi-Lingual books for kids and adults of all skill levels.
Hi,
If you look at section 4 in the datasheet you'll see a note there saying:There's also an example showing how to do it but it's in ASM so it's not that easy to understand.Note: The ANSEL and CMCON0 registers must be initialized to configure an analog channel as a digital input. Pins configured as analog inputs will read ‘0’.
If you then look at figure 8.4 you'll see the various configurations for the comparator module and in the bottom right hand corner it shows that you should write 7 (the three lower bits are set) to CMCON0 in order to disable the comparator.
If you then look at the bottom of table 2.2 it'll show you that ANSEL "comes up" with the lower 4 bits set and if you look at register 4-3 (page 33) you'll see that when bit 0-3 is set it means that the pin is in "analog mode".
As for the rest, $9F is the adress for ANSEL register and $19 is the adress for the CMCON0 register and that can be found if you look at figure 2.2 in the same datasheet. PBP makes it a lot easier as it allows you to write directly the the registers without having to look up the actual adress of it "manually".
It's a very common thing to overlook untill you've been bitten by it, next time a pin doesn't work as you think it should it'll be the first thing you'll think of checking ;-)
/Henrik.
oy...
Thanks guys, you rock..
How I wish I could be using my Arduino for this project..
www.theLanguageBear.com - Multi-Lingual books for kids and adults of all skill levels.
Bookmarks