PDA

View Full Version : 16F689 PORTB.7 Problem



jderson
- 5th April 2008, 03:56
I am using this pin as an input. I had "TRISB = %1000" at the front of my program, and this pin would always come up as an output, in the low state. This is a 4 bit port, and the data sheet says the lower 4 bits of TRISB are ignored. It appears that this is not the case, for when I change to "TRISB = %10000000", it works! Can someone confirm this for me, so I'll know I'm not crazy?

Thank you.

b1arrk5
- 5th April 2008, 04:09
You're right. Trisb=%1000 is setting the lower four bits, which are ignored. This command would set portb.3 as an input, but your particular PIC doesn't have a portb.3 port, so it doesn't work, and is ignored. Trisb=%10000000 will indeed set portb.7 as an input.

Jerry

jderson
- 5th April 2008, 04:32
Does this mean the data sheet is wrong, or am I just misinterpreting it?

skimask
- 5th April 2008, 06:43
Does this mean the data sheet is wrong, or am I just misinterpreting it?

The datasheet is right. It specifically states that the lower four bits are unimplemented, which in the Legends for the various pages it states that unimplemented bits are read as '0'. And to that end, I remember reading a long time ago in one of those PIC XXxxxx Family Reference manuals that writes to unimplemented bits are discouraged, most like just because they are exactly that...unimplemented. (Remember the Z-80 back in the day, there were a bunch of bit codes that were 'unimplemented' and turned out to be extended instructions that didn't quite work out the way they'd planned)