2012-02-22 08:14 AM
Dear All,
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), #metoo-maybe2012-03-05 04:21 AM
2012-03-05 05:03 AM
So how's this noise entering the system, and how would you mitigate that, or detect it?
If you're pushing the SPI signal over a long distance, have you considered a shield cable and differential drivers/receivers?2013-10-11 02:40 AM
Hi,
I also have this problem but i have no idea what cause the false communication . It happens at random. Anyone has an idea what ahs gone wrong? Thanks2013-10-12 10:21 AM
Anyone has an idea what has gone wrong?
Instead of playing this game, please state fully your situation and conditions.