cancel
Showing results for 
Search instead for 
Did you mean: 

Setting up GPIO and SPI for hardware slave select management. /NSS is never set to HIGH. Is there a bug?

Breakthecake
Associate II

I am writing a SPI driver for STM32L476RG, which is on a Nucleo board. First use: Communicate with an EEPROM to see how SPI works, logic analyzer records the bits.

The slave seems not to react. I found out the /NSS pin is never High. As far as I get the idea of HW slave management there should come a Low to select the chip. The data sheet of the slave mentiones it needs a transition from H to L to feel selected by the master.

Stepping through the init process of GPIO and SPI I cannot see the level of the /NSS pin ever changing from L to H, not even after activating the SPIx by setting the SPE bit in CR1 register. The logic analyzer delivers the same result. The clock signal and the MOSI data of the master (STM) are fine.

To set up the HW slave management I set

  • SSM to L
  • SSI to L
  • SSOE H
  • master mode
  • full duplex

which I could see in the registers.

I set the /NSS pin to Alternate function.

Right now I have no idea any more where to search for hints... Any idea is appreciated.

Ciao Andreas

2 REPLIES 2
KnarfB
Principal III

NSS is either low or high-Z (tri-state). The ref.man doesn't say that explicitely and NSS is a common source of misunderstandings. You can activate the internal pull-up or better use an external (stronger) pull-up. In many cases it is simpler to use any GPIO as a software SS and manage that by software. But, introduces additional delays, especially when using HAL. For a ws25 library, check https://github.com/NimaLTD

hth

KnarfB

Breakthecake
Associate II

Hi,

what you wrote sounds absolutely reasonable and simple. Actually, I did not use any pull-ups, as it was never mentioned in the online course I took part. The MOSI line worked fine, so I did not start to think about that issue. I will change that.

Thanks for your valueable information about SW SS and GPIO usage. I thought about that, when addressing more than one slave on the SPI bus. I will check the lib.

The quoted library ws25 has got a new name: ws25xx.