Skip to main content
vbk22398
Senior
Mar 17, 2024 11:13 AM UTC
Question

SPI Transmit and Receive in STM32F207ZGT6

int main(void)

{

HAL_Init();

 

SystemClock_Config();

 

MX_GPIO_Init();

MX_SPI1_Init();

MX_USART3_UART_Init();

/* USER CODE BEGIN 2 */

----> HAL_SPI_Receive_IT(&hspi1, (uint8_t*) &rx_data, sizeof(rx_data));

/* USER CODE END 2 */

while (1)

{

HAL_SPI_Transmit(&hspi1, (uint8_t*) &test,sizeof(test), HAL_MAX_DELAY);

delay(10000);

}

}

I use SPI1 module in FullDuplexMaster Mode.
I use interrupt to receive data from the SPI Slave.
The Thing is that if I add the Line which is arrowed--->HAL_SPI_Receive_IT(), the sending is not happening.
I want to know why this is happening. help me why?

Thank You

This topic has been closed for replies.

3 replies

STTwo-32
ST Technical Moderator
Mar 17, 2024 11:20 AM UTC

Helll @vbk22398 

I suggest you to take a look at this example to understand how it works.It should be helpful on your case.

Best Regards.

STTwo-32 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
AScha.3
Super User
Mar 17, 2024 12:03 PM UTC

Try with (only using) : 

HAL_SPI_TransmitReceive(..);

on full duplex spi, always both happen together, transmit and receive, see rm :

 

AScha3_0-1710677165844.png

 

If you feel a post has answered your question, please click on " Best Answer ".
gbm
Super User
Mar 17, 2024 1:49 PM UTC

Use HAL_SPI_TransmitReceive().

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice