2025-07-15 4:01 AM - last edited on 2025-07-15 4:37 AM by Andrew Neil
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.
2025-07-18 3:25 AM - edited 2025-07-18 6:24 AM
Hi TDK and Andrew,
Thank you for information and support.
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
2025-07-20 9:55 PM - last edited on 2025-07-21 6:45 AM by Andrew Neil
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
Note : Please check once the image that I have shared.
B.R
Ash
2025-07-21 12:29 AM
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
2025-07-21 1:23 AM - edited 2025-07-21 1:24 AM
@Ash1 wrote:The Requirement is to use Peripheral controlled CS hence I cannot use GPIO.
Why is that a requirement?
The slave device neither knows nor cares how the CS signal is driven - just that it works as required.
@Ash1 wrote:
- Is this intended behavior??
As @waclawek.jan suggests, the defined behaviour is that CS stays low until the SPI is disabled:
via: https://www.st.com/en/microcontrollers-microprocessors/stm32f407zg.html#documentation
@Ash1 wrote:
- Why additional time needed and what is the functionality executed in this period?
the delay you're seeing is probably the time that it takes to disable the peripheral.
At zero optimisation (which is the default for the STM32cUBEide Debug configuration), stuff can be very slow - especially HAL stuff.
So what optimisation level are you using?
It may or may not be quicker to manage the CS "manually" using HAL calls (also subject to optimisation, of course).
It probably would be quicker to do it via direct register access.
2025-07-21 5:55 AM - last edited on 2025-07-21 6:46 AM by Andrew Neil
Duplicate:
SPi communication in stm32f407vgtx board - STMicroelectronics Community
Now merged.