View Full Version : Ok....I'm sort of confused....about getting bit value.
02-18-2007, 02:33 AM
Ok....so I'm working with a chip that places a 1 into bit #2 of a word.
I have included the code I'm trying to look at this bit with....but I'm concerned it not actually working the way I need it to.
It is in spin.....so you asm guys cut me some slack.
· goodch1 := (bs2.shiftin(SDI, SCL, bs2#MSBPRE, 16))
· if goodch1.byte & |<2
I'm wondering if I'm even close.....maybe I should have stuck with stamps.
02-18-2007, 02:49 AM
It's a little confusing because of the byte/word order thing. The Propeller stores information in "little-endian" order where the "little end" of the word or long comes first. BYTE[ 0] is the low order byte of the word while BYTE[ 1] is the high order byte. This may not be what you're trying to do (in fact, I think it's backwards for you). It's actually easier to just leave things as words. Use "goodch1 & |< 2" in the IF statement and I think things will work better and possibly be clearer.
02-18-2007, 02:52 AM
Wouldn't bit #2 be on the lower end of the word?
Also....since this data is coming in MSB.....would that make it backwards.....
I'm tried the suggested way first.....but didn't seem to work....but this is not the only part that is confusing.
Just to make sure....the bits are numbered· 0 - 15 ....right?
I want to ensure I'm getting all the terminology right.
Post Edited (James Long) : 2/17/2007 6:58:13 PM GMT
02-18-2007, 03:44 AM
Most people number the bits from least significant (2^0) to most signficant, but that's not always true. Based on your documentation, you'll have to figure out how your device numbers them. The Propeller and its software assumes that bit #0 is the least significant.
02-18-2007, 06:06 AM
I checked the datasheet....and the word is numbered from MSB to LSB (D15 to D0)
So I figure the least significate would be on the bottom end....or the last recieved by the Propeller. Which I would calculate would be the lower end of byte.
But I seem to not be recieving any 1's from the chip. Seems to only give zero's by the few tests I have run, which all may be wrong.
The shiftin method should put the bits in order with the MSB being to the left. That is why I calculate the LSB being to the farthest to the right. (Which I assume is the byte).
I have to get an oscope to insure the chip is outputing data.