cancel
Showing results for 
Search instead for 
Did you mean: 

SPI BSY flag

stuart239955
Associate II
Posted on February 22, 2012 at 17:14

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-maybe
4 REPLIES 4
stuart239955
Associate II
Posted on March 05, 2012 at 13:21

Hi all,

Had no responses, so I'm refreshing this issue to keep it in the 'recent list' on the forum.

Anyone got any ideas?

Thanks.

Posted on March 05, 2012 at 14:03

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?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
siewkim
Associate
Posted on October 11, 2013 at 11:40

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?

Thanks

Posted on October 12, 2013 at 19:21

Anyone has an idea what has gone wrong?

Instead of playing this game, please state fully your situation and conditions.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..