cancel
Showing results for 
Search instead for 
Did you mean: 

SPi communication in stm32f407vgtx board

Ash1
Associate III

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

 

14 REPLIES 14
TDK
Super User

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".
Ash1
Associate III

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

 

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".
Ash1
Associate III

Hi 

What about the clock ..I want to know when I will start seeing clock and when it goes off, who actually controls the clock .

B.R

Ash

Ash1
Associate III

hi stm32' community

I am sharing you zip of my project can you check my spi code is it correct on logic analyzer or anywhere.

I request you to help me to achieve SPI communication.

Ash1_0-1752659572522.png

I am sharing screenshot you can clearly in the end you may notice a time gap how late cs goes high even when I have disabled cs immediately after reading SPI_dr register.

Ash1
Associate III

Hi

I am waiting for your response .

B.R

Ash

> HAL_SPI_Transmit(&hspi1, TX_Buffer, 1, 1000);

This is the only SPI-related statement in your code. I don't see manipulation of CS anywhere or disabling the SPI peripheral anywhere.

Still stand by my first statement. NSS will be low as long as the peripheral is enabled. Better to use a GPIO pin here.

If you feel a post has answered your question, please click "Accept as Solution".

@Ash1 wrote:

who actually controls the clock .


By definition, it is the Master which controls the clock in SPI.

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.

@TDK wrote:

Still stand by my first statement. NSS will be low as long as the peripheral is enabled. .


Indeed - that is the defined behaviour:

AndrewNeil_0-1752761835408.png

https://www.st.com/resource/en/reference_manual/rm0090-stm32f405415-stm32f407417-stm32f427437-and-stm32f429439-advanced-armbased-32bit-mcus-stmicroelectronics.pdf#page=880

via: https://www.st.com/en/microcontrollers-microprocessors/stm32f407vg.html#documentation

 

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.