I have two separate STM32F103's communicating to each other by SPI. I've configured one as a master & the other as a slave. I'm using DMA to automate the SPI transfer.
I've used the ST Library (3.5.0) examples as the basis of my code.
Since the master controls the SPI clocks, a hardware IO line is used to signal the master that the slave is ready to receive. The slave outputs / drives this IO line, the master inputs / looks at this line. This is effectively a 'handshaking' signal from slave to master.
My SPI messages are variable length. Therefore, the master communicates to the slave as to how many bytes are to be received. This is a fixed, two byte message plus a checksum) that is always sent first. The rest of the messages will follow, once the slave is ready.
The slave (which is waiting for this length to be sent) receives this and sets itself up to receive the rest of the bytes via DMA. Once ready, the slave signals the master (via the 'SlaveReady' IO pin) that the remaining data can now be sent.
Normal communication works just fine.
However, if there's a spike of noise (e.g. caused by a fluorescent light turning on), this gets on the SPI lines and cause a false communication. This means that the slave has its SPI Status Register BSY pin set, but no data has been received.
Once the BSY pin is set, it stays set (I guess an incomplete message has been received and it's waiting for more). I can't seem to clear it - even disabling and re-enabling the SPI peripheral seems to have no effect.
This means that the slave SPI will not receive correct amount of data (as its already received some via the noise).
How can I get the BSY line to clear? The BSY line is read-only and is only set via hardware.
Thanks (in advance),