2011-10-19 07:46 AM
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? Mike2011-10-19 04:44 PM
Is the SPI status register showing any errors when this happens?
2011-10-20 07:36 AM
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 threadhttps://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¤tviews=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.2011-10-21 12:02 PM
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.