General Category > Discussion - Software

FT900 SPI read library error

(1/1)

scorpioprise:
Hi everybody,
I have to admit my ignorance, but I asked more experts and I had the following solution.

I was using an external ADC as slave, that was sending me back wrong / corrupted packets.

The Library given (2.5.0) for spi has a bug in spi_readn(), that is the
--- Code: ---uint8_t FifoScratch[64]
--- End code ---
variable is not initialized to zero.
Thus, when reading from spi, this leads to a spurious writes where there should be none and, as in my case, the slave recives data when not supposed, sometimes leading to erratic behaviour.
Simple solution, add to the original code, just after the declaration, a 
--- Code: ---
for (int j = 0; j < 64; j++) {
FifoScratch[j] = 0x00;
}
--- End code ---
or whatever you like.

Hope this helps future users.

Navigation

[0] Message Index

Go to full version