I am reading bit PE1 in an ISR using BitRdPortI.
I was surprised when it returned the value 2… when the documentation says it returns 0 or 1.
Since I am reading bit #1, I assume that BitRdPortI is returning 0000 0010 (binary)… which is 2.
Is this how BitRdPortI is expected to work?
Ion
Not according to documentation, it should return 0 or 1 for the specified bit. Are you sure you supply the correct portnumber and bit nr (between 0-7) ?
On what portnumber is PE1?
[QUOTE=PerfConn;1447]Not according to documentation, it should return 0 or 1 for the specified bit. Are you sure you supply the correct portnumber and bit nr (between 0-7) ?
On what portnumber is PE1?[/quote]
This is how I use BitRdPortI to read PE1:
int result = BitRdPortI(PEDR, 1);
I am calling this in an ISR that I set up for PE1. (I buffer up values and printf them at the end of a run.)
Could it be that calling it from within the ISR is the problem?
This is a hobby for me, so I’ll have to wait until after work to try anything further.
I will have to try connecting inputs to other bits and experiment more with BitRdPortI.
Tech support has informed me:
“The BitRdPortI returns a 1 or 0 in the bit position of the requested bit. Since you asked for bit 1 you will get either a 2 or a 0.”
IMO, the documentation could be more clear.
Ion