2021-02-26 08:03 AM
Hi all,
I'm working on a project that will communicate via SPI. I want to use DMA for it. I have some problem getting HAL_SPI_TxCpltCallback to be called. I've followed the debbuger and I think I've found what's wrong. It seems that the SPI_DMATransmitCplt function is not checking the hspi instance at the right address.
Here is the state of the right hspi instance before beginning the transmission. Notice the byte is set to 0x1 (HAL_SPI_STATE_READY).
Here is the same variable after the hspi state has been put to 0x3 (HAL_SPI_STATE_BUSY_TX).
So far, so good. The transmission occurs and then the HAL_DMA_IRQHandler is called. The SPI_DMATransmitCplt function is then called. In this function, there is the line
SPI_HandleTypeDef *hspi = (SPI_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
This line is supposed to return the hspi instance previously mentionned. Instead, it returns another instance with its state set to 0x1 (HAL_SPI_STATE_READY).
This means that HAL_SPI_IRQHandler will never call HAL_SPI_TxCpltCallback as the if statement will return false.
I'm using the firmware package V1.8.0
Am I missing something? Any help would be appreciated.
Solved! Go to Solution.
2021-03-01 06:25 AM
Found what was wrong. It's a mistake on my side as I thought. It was not checking the right memory address because instead of pointing to the hspi1 address I had made a copy of it (with a different address).
2021-03-01 06:25 AM
Found what was wrong. It's a mistake on my side as I thought. It was not checking the right memory address because instead of pointing to the hspi1 address I had made a copy of it (with a different address).