0
votes

my SPI kernel clock at 400Mhz and prescaler 256 at this configuration alone, my SPI is generating Clk, MISO,MOSI, CS signals, when I change the Prescaler Value other than this value, none of the signals are generated, the code enters into a Loop, Device busy status is returning.

With this configuration, only 1.56Mhz SPI clk speed is running. I want to increase the SPI clk speed. Pls help me out.

My SPI Init is as follows:

hspi1.Instance = SPI1;
hspi1.Init.Mode = SPI_MODE_MASTER;
hspi1.Init.Direction = SPI_DIRECTION_2LINES;
hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
hspi1.Init.CLKPolarity = SPI_POLARITY_HIGH;
hspi1.Init.CLKPhase = SPI_PHASE_2EDGE;
hspi1.Init.NSS = SPI_NSS_SOFT;
//hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256;
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8;
hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi1.Init.CRCPolynomial = 7;
hspi1.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;

I want to execute the SPI clk at 80 or 100 Mhz which is the max execution speed of SPI in STM32.

1
Are you aware of all the tough requirements that the hardware needs to fulfil in order to run SPI that fast? Why do you need such extreme speeds?Lundin
Thank you Lundin, I am using SPI NOR Flash. Its normal read/write can be done at 80Mhz. My filesystem LittleFS gets executes properly sometimes, and most of the time device busy status occurs. hence thought of increasing the clk.Indu
Have you configured proper slew rate settings (IO speed settings) for the GPIOs that you use as output pins?th33lf
@Lundin, I was able to do SPI communication between two STM32H7 Nucleo boards connected with basic wires at around 100MHz. Could you elaborate on the touch requirements you are mentioning ?Guillaume Petitjean
Thank you @ Guillaume Petitjean and @th33lf. Changed the speed to Very high, it worked.Indu

1 Answers

2
votes

I've had the exact same issue and it was due to the GPIO output speed setting. You should check and change it to Very High Speed (register GPIOx_OSPEEDR).