Skip to main content
Associate III
July 15, 2025
Solved

SPi communication in stm32f407vgtx board

  • July 15, 2025
  • 2 replies
  • 784 views

Hi all

I am working with SPI1 on stm32f407vgtx and issue what I am, facing my NSS which internally controlled by SPI is taking more time for goes high even CLOCk has been stopped . my configuration are SPI full duplex 16 bit data clock is 2.6MHZ after prescaled I am transmitting on spi every 10ms task. Please check the screenshot of logic analyzer for further understanding .

Note: in the end I have disabled SPE bit  before checking TXE and busy flags.

 

Ash1_0-1752577116863.png

 

2 replies

TDK
Super User
July 15, 2025

NSS remaining low is not a problem for the SPI protocol. On the STM32F4, NSS will remain low as long as the SPI peripheral is enabled. I recommend using a GPIO pin for the CS pin.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Ash1Author
Associate III
July 15, 2025

Hi

I have a observed that every times after 4th CLOCK 5th clock is taking twice than rest.

why it happening please check the image.

Ash1_0-1752590660103.png

 

TDK
Super User
July 15, 2025

This is a sampling rate issue. Increase the sampling rate on the logic analyzer and/or slow down the SPI clock speed if this bothers you.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Ash1Author
Associate III
July 21, 2025

Duplicate - merged.


Hi all

The slave device I intend to use needs to use requires CS to toggle with each SPI Command [16 bit length]. The Requirement is to use Peripheral controlled CS hence I cannot use GPIO.

During Transmission we are able to observe the Data correctly over MOSI. Currently Default 0xFF on MISO as Slave is not connected.

The issue we see is additional ~1.5 us is taken by SPI controlled CS to go to High after Clock stops.To make CS high SPI is disabled via bit SPE =0 in CR1 after TXE = 1 and BSY= 0

  • Is this intended behavior??
  • Why additional time needed and what is the functionality executed in this period?
  • Is there any default Setup Delay or Hold Delay implemented as SCI Clocks stops 1.4us before the SCI is High?

Note : Please check once the image that I have shared.

Ash1_0-1752844768076.png

B.R

Ash

waclawek.jan
Super User
July 21, 2025

The SPI hardware does not set NSS (CS) high actively.

If you use Cube/HAL, it probably disables SPI entirely (by clearing SPIx_CR.SPE) after transmission. This threestates the SPI pins, i.e. does not pull them up actively, although you mayu have enabled internal pullups on the NSS (CS) and SCK pins.

You can try to set the NSS (CS) pin to GPIO output and control it in software to generate the required framing, but again if you rely on Cube/HAL, the software overhead of it may prevent you to act quickly enough.

JW