2023-03-20 05:55 AM
Hello to everybody,
I have program for stm32f103 mcu. Now I want to do my SPI transmit routine using interrupt.
Before:
HAL_StatusTypeDef status = HAL_SPI_Transmit(&afe_spi, (uint8_t*) pData, 4,100);
Now I tried this (and many variants also):
HAL_StatusTypeDef status = HAL_SPI_Transmit_IT(&afe_spi, (uint8_t *) pData, 4);
while (status != HAL_OK){
status = HAL_SPI_Transmit_IT(&afe_spi, (uint8_t *) pData, 4);
}
But data isn't sended. And in debug mode i can see:
My project settings:
Other interrupt also not works.
Best regerds, Egor
Solved! Go to Solution.
2023-03-20 08:23 AM
I changed &afe_spi to &hspi1 and it works! I forget about pointer =0
Thanks to everybody
2023-03-20 06:53 AM
Hi @EBurk.1 ,
looks like you didn't implement the callbacks correctly. The IRQ handler will use callback functions to notify your software about events, like for example buffer empty or buffer full. You need to implement these. Look at some examples from the intro pack repository to get inspiration.
BR,
J
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.
2023-03-20 07:38 AM
Where and how is afe_spi defined?
JW
2023-03-20 07:45 AM
afe_spi is hspi1 SPI_HandleTypeDef
main.c:
AFE_INIT(hspi1);
and my afe.c:
void AFE_INIT(SPI_HandleTypeDef hspi) {
afe_spi = hspi;
...
Without interrupt Tx and Rx working, but i can't get how to implement callback function. I need just to send data with interrupt without any special things for a start
2023-03-20 08:02 AM
OK so how is hspi1 defined?
In debugger, look at where it is placed in memory, and what it its content, and show.
JW
2023-03-20 08:08 AM
// HAL_StatusTypeDef status = HAL_SPI_Transmit(&afe_spi, (uint8_t *) pData, 4, 100); // works fine
HAL_StatusTypeDef status = HAL_SPI_Transmit_IT(&afe_spi, (uint8_t *) pData, 4);
while (status != HAL_OK){
status = HAL_SPI_Transmit_IT(&afe_spi, (uint8_t *) pData, 4);
}
2023-03-20 08:23 AM
I changed &afe_spi to &hspi1 and it works! I forget about pointer =0
Thanks to everybody
2023-03-20 09:06 AM
For IT and DMA also watch the scope of the data pointer (pData)
Using local/auto variables for parameters passed in can lead to stack data corruption and failure if/when the scope collapses.