cancel
Showing results for 
Search instead for 
Did you mean: 

Strange SPI failure

kk6gm
Associate II
Posted on October 19, 2011 at 16:46

I'm playing around with SPI (SPI2 on the VL discovery board), and am able to configure the chip as a master and I see the clock and data outputs.  Right now I'm using polling to transmit - interrupts can come later.  What is strange is that after a few seconds of running, the SPI output not only stops, but the output pins (SCK and MOSI) go floating.  I can tell this because they get wavy on the scope.  If I reset the discovery board everything works again for a few seconds.

I should add that the rest of my program (I'm reading buttons and an ADC channel and updating an LCD character display) continues to work after the SPI stops.

Any thoughts on what might be going on here?

Mike

3 REPLIES 3
infoinfo989
Associate III
Posted on October 20, 2011 at 01:44

Is the SPI status register showing any errors when this happens?

kk6gm
Associate II
Posted on October 20, 2011 at 16:36

I haven't had a chance to get back to the hardware, but I'm convinced that the problem is related to using the NSS pin/feature. I suspect the master is going into fault and switching to slave mode, hencethe variousoutputs e.g. SCKbecoming inputs.

I found this thread

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/SPI problem with hardware NSS management&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=9343

and it seems that hardware NSS is either (a) buggy or (b) widely misunderstood. So I've probably got enough info to make a fix e.g. using GPIO to drive the slave NSS input.

kk6gm
Associate II
Posted on October 21, 2011 at 21:02

Got the SPI working, driving the NSS pin as GPIO.  Count me in the group that thinks the default HW handling of the NSS signal is weird.