28x1 PortA Reading

mildenhall

New Member
I am having trouble reading the logic state of pins on PortA of a 28x1. I have managed to do...

Code:
if PortA pin0 = 0 then
  b2 = 0
else
  b2 = 1
endif
but what I would like to do is sdomething like this...

Code:
b2 = PortA pin0
however I get a syntax error. Do I just need to stick with my first method or is there a way to do it like the second method please?

TIA
 

hippy

Ex-Staff (retired)
This is a limitation of the 28X1, you have to do it the first way.

You can read the entire set of PORTA pins in one go by peeking SFR and you can get at individual pins with shifting and masking but it's not elegant. The cleanest way perhaps is to put it as a single line -

if PortA pin0 = 0 then : b2 = 0 : else : b2 = 1 : endif
 
Top