'Rotate Left' Not Rotating
lardom
Posts: 1,659
in Propeller 1
The manual says 'rotate left' causes the MSB to rotate to the LSB. The second expression 'should' return 225. What am I missing?
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 OBJ pst : "Parallax Serial Terminal" VAR byte temp PUB main pst.Start(57600) WAITCNT(clkfreq + CNT) one := (%00011110 << 4) 'shift left pst.dec(one) pst.Chars(pst#NL, 1) pst.bin(one, 8) pst.Chars(pst#NL, 1) one := (%00011110 <- 4) 'rotate left pst.dec(one) 'both return 224 pst.Chars(pst#NL, 1) pst.bin(one, 8) pst.Chars(pst#NL, 1)
Comments
Here's a routine that may help you do 8-bit SPI -- output and input is MSBFIRST.
The output byte gets moved into BYTE3 so that it the MSB can be rotated into BIT0 for output. After clocking that bit out, the input (MISO) line is checked b.bit0 is set or cleared as required. There are not bit operators in Spin, so we have to do with with a mask.
As soon as I saw: I said "That's it!"
MISO was the next hurdle. Thank you. The datsheet for the nRF24L01 says MISO and MOSI are shifted in/out simultaneously. I believe I have to shift out $FF for every byte I want to read out of the device. I have been trying to get telemetry to work.
In 'my' experiments I assumed '+=' would be the logical choice because it 'didn't' overwrite the previous value.