| Posted: 01:00pm 08 Nov 2019 |
Copy link to clipboard |
 Print this post |
|
Haven't done much with SPI and I RTFM but am still confused:
So this following code works well and MSB comes first. I then sum the bytes to get a 32bit "Count"...
SPI OPEN 10000000, 0, 8 ' speed is 10MHz and the data size is 8 bits
PIN(69) = 0 ' assert the enable line (active low) junk = SPI(&H60) ' send the command and ignore the return byte1% = SPI(0) << 24 ' get the first byte from the slave byte2% = SPI(0) << 16' get the second byte from the slave byte3% = spi(0) << 8 byte4% = spi(0) Count% = byte1% + byte2% + byte3% + byte4% PIN(69) = 1 ' deselect the slave'
Reading about the "Bulk Read", as an option, it suggests loading the bytes into an array...I would still need to build the required 32bit value.
Is it possible to OPEN as 32 bits and simply read directly into a MM integer?:
SPI OPEN 10000000, 0, 32
|