Closed plusk01 closed 6 years ago
I fixed this issue by instead using the transfer transfer complete (DMA_IT_TC
) interrupt on the Rx side (DMA1_Channel2_IRQn
) (which makes intuitive sense -- before the uC was being interrupted after it finished transmitting, but not necessarily after it received all the data from the MPU).
SPI with DMA and interrupts is now working.
Note! The reason this issue came up in the first place was because I set the SPI clock to ~500 kHz for configuration, but never increased the clock for data transfer. I tested setting the clock to 18 MHz while using the Tx DMA_IT_TC
(DMA1_Channel3_IRQn
) and it worked just fine.
I'll leave SPI using Rx since it is more intuitive.
When using DMA-enabled SPI and using the Tx channel ISR (
DMA1_Channel3_IRQn
), the data that received from the MPU seems to be shifted by 4 bytes.If I disable the interrupt and instead just wait for the transfer to complete, I get the right result.
Thus, it seems to be directly related to the
DMA_ITConfig(cfg_->Tx_DMA_Channel, DMA_IT_TC, ENABLE)
interrupt.