2025-12-19 7:43 AM
Hi all,
I am working on firmware that involves SPI communication using a Nucleo board (Nucleo-L4R5ZI-P) with an STM32L4ZIT6 microcontroller.
I am trying to establish communication with an SPI slave device. The chip select (NSS) signal is expected to be controlled by hardware, so I enabled the hardware chip-select configuration as shown below.(screenshots attached)
When I switch to software control, I am able to read from and write to the slave registers by manually toggling the chip-select pin in software. However, when I change the mode to SPI_NSS_HARD_OUTPUT, the SPI read/write communication stops working.
What could be the issue?
2025-12-19 8:06 AM
NSS is low as long as the peripheral is enabled. It doesn't just go low for the transaction. This is typically not what you want and the "hardware NSS" setting on this chip is often not useful.
The best way to handle this is to initialize the pin as a GPIO output and control it manually.
2025-12-19 9:36 AM
Set pulse enable
hspi1.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;