I'm trying to talk to an accelerometer via software SPI, but can't seem to get the SHIFTIN command working.
Code:
iSDO = 0
AccRegister = $F
ACC_Chip_SEL = 0
AccRegister.7 = 1
AccRegister.6 = 0
shiftout SDo,SPICL,5,[AccRegister]; 5 is the mode
shiftin SDI,SPICL,5,[SPIData]
ACC_Chip_SEL = 1
hserout [cr,lf,hex2 SPIData]
A screenshot of what I get out of my logic analyzer is at:
www.charleslinquist.com/SPI.jpg
The SHIFTOUT command appears to be working well, but the SHIFTIN command shows "0" even though the logic analyzer shows that 0x32 is being returned.
What am I doing wrong?
Bookmarks