Skip to main content
JovanCicic021
Associate
May 2, 2025
Solved

SPI STM32H743 function problem

  • May 2, 2025
  • 1 reply
  • 2601 views

Hi, I have problem with my SPI peripheral. For generate inicial code I used STM32 Cube IDE Version 6.14.1, and programming IDE STM32 Cube IDE Version 1.18.1.

Description of problem:

1.I want simple to check loop with transmit and receive data, but when I do that I always have 0 or 255 in receive register. I tried the same thing with UART, and it works.

2.On SCK I don't have clock, I try with oscilloscope to see but nothing.

 
In attachment I leave full project and video, please can someone check and say me some advice.
 

 

Best answer by TDK

> 1.I want simple to check loop with transmit and receive data, but when I do that I always have 0 or 255 in receive register. I tried the same thing with UART, and it works.

> //HAL_UART_Transmit(&huart4, &b, 1, 100);
> //HAL_UART_Receive(&huart4, &d, 1, 100);
> HAL_SPI_Transmit(&hspi4, &b, 1, 100);
> HAL_SPI_Receive(&hspi4, &d, 1, 100);

SPI is not asynchronous like UART. Data is sent and received at the same time. To send and receive one byte:

HAL_SPI_TransmitReceive(&hspi4, &b, &d, 1, 100);

If MOSI is connected to MISO, then the received data (d) will match the sent data (b).

 

 

> 2.On SCK I don't have clock, I try with oscilloscope to see but nothing.

> GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

Set SPI pin speed to very high, or reduce clock rate.,

 

1 reply

TDK
TDKAnswer
Super User
May 2, 2025

> 1.I want simple to check loop with transmit and receive data, but when I do that I always have 0 or 255 in receive register. I tried the same thing with UART, and it works.

> //HAL_UART_Transmit(&huart4, &b, 1, 100);
> //HAL_UART_Receive(&huart4, &d, 1, 100);
> HAL_SPI_Transmit(&hspi4, &b, 1, 100);
> HAL_SPI_Receive(&hspi4, &d, 1, 100);

SPI is not asynchronous like UART. Data is sent and received at the same time. To send and receive one byte:

HAL_SPI_TransmitReceive(&hspi4, &b, &d, 1, 100);

If MOSI is connected to MISO, then the received data (d) will match the sent data (b).

 

 

> 2.On SCK I don't have clock, I try with oscilloscope to see but nothing.

> GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

Set SPI pin speed to very high, or reduce clock rate.,

 

"If you feel a post has answered your question, please click ""Accept as Solution""."
JovanCicic021
Associate
May 3, 2025

Thank you very much, first question solve, and in attachment video how it is working (SPI_STM32H743).

I didn't use GPIO A7 for synchronize periphery, I used SCK pin from SPI. I try to see physically external clock, how synchronized slave.

With this GPIO A7 I selected slave, and that worked.

I am trying to read MPU 9250 gyroscope, but I can't. And I am not sure witch parth not working.