PDA

View Full Version : Reading the port - Little help needed



Megahertz
- 26th June 2011, 13:15
I would like to ask if someone can suggest me how should I write the following statement as the current one is not working:


While PortC=%111011 & %001000
Serout ToTx,N2400,[66]
wend

I want to check if ONLY PortC.2 is pulled low & rest are held high. I want to exclude PortC.3 from being read as it has another function attached to it. It's state (PortC.3) should not be considered. Thanks

mister_e
- 26th June 2011, 14:15
WHILE (PORTC = %11111011) OR (PORTC = %11110011)
SEROUT ToTx, N2400, [66]
WEND

mister_e
- 26th June 2011, 14:30
or


WHILE (PORTC = %11110011 | %00001000)
SEROUT ToTx, N2400, [66]
WEND
probably what you wanted to do at first ;)

Megahertz
- 26th June 2011, 18:32
"| %0000100"
What does this does mister_e? I read the manual it says there that this "|" is used to set the bit. Please explain how it fits with my requirement. Thanks a lot

mister_e
- 26th June 2011, 19:15
it's all about Bitwise operations. (http://en.wikipedia.org/wiki/Bitwise_operation)

| is bitwise OR.

You said you don't need to monitor bit.3?

So it could be 0 or 1?

How about making sure this specific is always 1 then?