Skip to main content
FAJOL.1
Associate II
September 18, 2024
Solved

Chip Select of SPI in Nucleo F401RE stuck low

  • September 18, 2024
  • 1 reply
  • 4542 views

Hi guys,

 

I m having an issue with my Nucleo F401RE. I m porting a code based on the use of SPI2 that worked very well on Nucleo G431RB. I made same setting on Nucleo IDE (see picture).

SPI Setting.jpg

 

After inizialization of periperhals NSS (Chip Select) goes to high and everithing seems to work fine until the first transmission:

 

 

 

void SPI_TX_16b(uint8_t* pdata){

	HAL_SPI_Transmit(&hspi2, (uint8_t*) pdata, 1, HAL_MAX_DELAY);

};

 

 

 

Then the NSS goes down and stucked there forever. In the picture (yellow is clk, green is data out, and violet is nss). 

 

Any ideas?

 

Thanks

 

scope_1.pngscope_0.png

This topic has been closed for replies.
Best answer by TDK

Don't use the hardware NSS pin on the STM32F4, it's not driven like a CS pin. It will always be low when the peripheral is active. Instead, initialize it as a GPIO output and manually set it low before transmission, and high afterwards.

 

1 reply

TDK
TDKBest answer
September 18, 2024

Don't use the hardware NSS pin on the STM32F4, it's not driven like a CS pin. It will always be low when the peripheral is active. Instead, initialize it as a GPIO output and manually set it low before transmission, and high afterwards.

 

"If you feel a post has answered your question, please click ""Accept as Solution""."
FAJOL.1
FAJOL.1Author
Associate II
September 18, 2024

ok fine. 

 

But why the IDE mentions "hardware NSS output signal" if Chip select is not automatically managed? In G431RB used to work automatically

 

Thanks

Andrew Neil
Super User
September 18, 2024
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.