PDA

View Full Version : Modifier error?



pedja089
- 5th June 2011, 15:27
When I try to access bits from the second byte in a array, strange things happen.


SEROUT2 tx,mode,[bin8 NDDate[0],13,bin8 NDDate[1],13,#NDDate.BIT7[1],#NDDate.BIT6[1],#NDDate.BIT5[1],#NDDate.BIT4[1]]

As a result I get this
0 0 1 1 0 0 1 0 (0D)
0 0 0 1 0 1 0 1 (0D)
1 0 0 1
If i try to access to first byte

SEROUT2 tx,mode,[bin8 NDDate[0],13,bin8 NDDate[1],13,#NDDate.BIT7[0],#NDDate.BIT6[0],#NDDate.BIT5[0],#NDDate.BIT4[0]]
Results:
0 0 1 1 0 0 1 0 (0D)
0 0 0 1 0 1 0 1 (0D)
0 0 1 1
It seems everything is OK. So what causing this error?
I'm using pbp 2.60C, PIC18F452

HenrikOlsson
- 5th June 2011, 15:39
Hi,
If NDDate is the byte array you access the 7th bit of the first byte (NDDate[0]) thru NDDate.0[7] and the 7th byte of the second byte thru NDDate.0[15].
Please see Melanies excelent writeup on the subject (http://www.picbasic.co.uk/forum/showthread.php?t=544&highlight=indexing+bits) for further details.

(Where's Melaine by the way, haven't "seen" her around for ages?)

pedja089
- 5th June 2011, 15:52
Thanks. Seems to be something I did not understand so well...