Hello @BDoon.1
What you're observing is indeed a common behavior when using DMA in circular mode, especially when the DMA is first initialized and started.
When you first start the DMA transfer, the DMA controller may generate a transfer-complete (TC) interrupt immediately. This can happen due to the following reasons:
-
Initial State: When the DMA is first enabled, it might consider the initial state as a "complete" state because it hasn't started transferring data yet. This can trigger the TC interrupt.
-
Buffer Initialization: The DMA controller might be initializing the buffer pointers and other internal states, which can cause it to generate a TC interrupt as part of the setup process.
To handle the initial TC interrupt and ensure your application logic works correctly, you can implement a simple check in your interrupt service routine (ISR) to differentiate between the initial TC interrupt and subsequent ones.
Example of how you might implement this in your code:
void DMA_IRQHandler(void) {
if (DMA_GetITStatus(DMA1_Stream0, DMA_IT_TCIF0)) {
// Transfer Complete Interrupt
if (!initialTCHandled) {
// Handle the initial TC interrupt
initialTCHandled = true;
} else {
// Handle subsequent TC interrupts
// Your TC interrupt handling code here
}
DMA_ClearITPendingBit(DMA1_Stream0, DMA_IT_TCIF0);
}