cancel
Showing results for 
Search instead for 
Did you mean: 

SPI_DMATransmitCplt not checking the right address

lmbourassa
Associate

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).

0693W000007ZbyaQAC.pngHere is the same variable after the hspi state has been put to 0x3 (HAL_SPI_STATE_BUSY_TX).

0693W000007ZbyfQAC.pngSo 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).

0693W000007ZbykQAC.pngThis means that HAL_SPI_IRQHandler will never call HAL_SPI_TxCpltCallback as the if statement will return false.

0693W000007ZcBKQA0.png 

I'm using the firmware package V1.8.0

Am I missing something? Any help would be appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
lmbourassa
Associate

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).

View solution in original post

1 REPLY 1
lmbourassa
Associate

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).