TMS320F28375D: TMS320F28375D: DMA Channel Gets Stuck After Interrupt-Driven SPI Transfers

Part Number: TMS320F28375D

Device: TMS320F28375D

Peripherals Involved: SPI, DMA, External Interrupt

In our application, SPI DMA is used, interrupt-driven packet transactions. After running successfully for a large number of cycles (randomly between 19K to 85K transactions), the DMA channel completely halts because the PERINTFLG (Peripheral Interrupt Flag) gets stuck. Once this flag becomes stuck, no further DMA triggers are recognized, freezing all communication until a device reset.

 Implementation Details
 
 DMA configuration:
 
 //====================================================================================
    DMAInitialize();

    // Configure DMA CH5 (TX)
    DMACH5AddrConfig(&SpibRegs.SPITXBUF, send_frame.data);
    DMACH5BurstConfig(BURST, 1, 0);
    DMACH5TransferConfig(TRANSFER, 1, 0);
    DMACH5ModeConfig(DMA_SPIBTX, PERINT_ENABLE, ONESHOT_DISABLE, CONT_DISABLE,
                       SYNC_DISABLE, SYNC_SRC, OVRFLOW_DISABLE, SIXTEEN_BIT,
                       CHINT_END, CHINT_ENABLE);

    // Configure DMA CH6 (RX)
    DMACH6AddrConfig(dma_rx_buffer, &SpibRegs.SPIRXBUF);
    DMACH6BurstConfig(BURST, 0, 1);
    DMACH6TransferConfig(TRANSFER, 0, 1);
    DMACH6ModeConfig(DMA_SPIBRX, PERINT_ENABLE, ONESHOT_DISABLE, CONT_DISABLE,
                       SYNC_DISABLE, SYNC_SRC, OVRFLOW_DISABLE, SIXTEEN_BIT,
                       CHINT_END, CHINT_ENABLE);
 //====================================================================================
 
 DMA transfers are triggered by a peripheral/external hardware event (interrupt-driven). Both the transaction requests and the DMA TX/RX completely handled inside ISRs. A low-priority background routine runs in the main loop to check link status. However, this routine is strictly guarded by safety conditions:
 -> It only executes when no DMA transaction is active.
 -> It only executes when no request/response handling is in progress.

 Observed Behavior

 -> The system operates normally for thousands of consecutive, back-to-back interrupt-driven DMA bursts.
 -> Unpredictably (after 19K, 30K, 55K, or up to 85K successful transfers), the communication drops.
 -> Upon debugging during the fault condition, we found that the PERINTFLG bit for the specific DMA channel remains set/stuck, preventing the channel from recognizing subsequent trigger events.


1. What conditions or edge cases can cause a DMA channel's PERINTFLG to lock up or fail to clear when driven by peripheral interrupts?
2. Can main-loop status checks create a race condition with the DMA state machine or interrupt logic?
3. What is the recommended recovery procedure or best practice to safely reset/recover a DMA channel if its PERINTFLG gets stuck during runtime?

 

Sincerely,

Abhimanyu

  • Hi Abhinmanyu,

    Thank you for your question. I will look into it and reply back next week.

    Best Regards,

    Delaney

  • Hi Abhimanyu,

    This issue is quite odd. I don't know of a condition that should cause the PERINTFLG not to clear. Is the RUN bit set when the PERINTFLG gets stuck?

    Best Regards,

    Delaney

  • The RUN bit of the CONTROL register does not set when PERINTFLG is stuck. However, if I manually clear the PERINTFLG by writing 1 to the PERINTCLR bit(CH6), the channel immediately resumes working normally.

    Based on my review of the Technical Reference Manual (SPRUHM8K, Section 5.2.2 - Peripheral Interrupt Event Trigger Sources), I suspect this behavior is caused by the race condition described in the documentation: "If a peripheral trigger event occurs at the same time as the latched flag is being cleared, the trigger event has priority and the PERINTFLG remains set."

    Could this simultaneous occurrence be causing the flag to stay permanently latched in my application, and what is the recommended workaround or best practice to prevent or recover from this deadlock?

    The debugged DMA channel register values(during PERINTFLG stuck) are provided for your reference.

    Sincerely,

    Abhimanyu

  • Hi Abhimanyu,

    Apologies for the delay, I have been out of office. Please allow me another day to get back to you with a response.

    Best Regards,

    Delaney

  • Any update ma'am.

  • Hi Abhimanyu,

    Unfortunately, I still have not had a chance to look into this as I am held up with other tasks. I will try to reply back next week.

    Best Regards,

    Delaney