IMXRT EDMA error IRQ handler is not implemented in the SDK Hi, The IMXRT EDMA API in the SDK seems to handle "happy case" interrupts correctly. However, there doesn't seem to be any provision for handling error interrupts. Not only that, but it appears there is one global DMA_ERROR_IRQHandler for all DMA. So if you're using both DMA0 and DMA1, when things are "happy" the DMA0/DMA1 IRQHandler would be called and the SDK can distinguish which DMA got the happy interrupt. However, if there's a DMA error, since there's one global error interrupt handler, there's no easy way to know which DMA (0 or 1 or whatever) the error happened on. As in my previous question about LPUART error IRQ handling. Why isn't this baked into the SDK to handle DMA errors and call appropriate callbacks? Now I have to figure out how to determine which DMA the error is on by hand and call special handling outside the SDK instead of just having it call a callback for me. For an SDK that is supposed to be usable in production code, there seem to be a lot of missing robustness features, and I'm betting most people are just assuming these errors are handled under the hood by the SDK, and they don't think about the fact that they really aren't. -m Re: IMXRT EDMA error IRQ handler is not implemented in the SDK Dear @nxp16 ,
Which i.MX RT device are you using? When you mention DMA0 and DMA1, are you referring to two DMA channels rather than two DMA controller peripherals?
Not all i.MX RT devices have two eDMA controllers. For example:
i.MX RT1180 contains two eDMA controllers. In the startup file (for example, startup_mimxrt1189_cm33.c), you can find two DMA error handlers: DMA_ERROR_IRQHandler and DMA4_ERROR_IRQHandler.
i.MX RT1050 contains only one eDMA controller. In the startup file (for example, startup_mimxrt1052.c), there is only one DMA error handler: DMA_ERROR_IRQHandler.
In general, DMA errors are relatively infrequent events. From the hardware architecture perspective, channel error status is aggregated into a module-level error request, which triggers the DMA error interrupt. Therefore, the software must examine each channel's error status register (for example, CHn_ES) to determine which specific channel caused the error.
Best Regards,
Shelly Zhang
Re: IMXRT EDMA error IRQ handler is not implemented in the SDK Sorry, I meant channel. I'm using IMXRT1172. Wouldn't DMA errors occur if there was a problem with whatever peripheral it was being used with? I.e. if it was LPSPI with DMA wouldn't any SPI errors cause a DMA error? If not, then do SPI errors when using DMA trigger a SPI error interrupt? Thanks, -m Re: IMXRT EDMA error IRQ handler is not implemented in the SDK I figured as much. In that case, the SDK's transfer API is even less robust. Having to handle peripheral and DMA errors outside the SDK requires quite a bit of extra work, including somewhat hacky overriding of the default IRQ handlers and making sure they still call into the SDK handlers after processing any errors. The fact that this stuff isn't part of the SDK transfer API is very discouraging. Re: IMXRT EDMA error IRQ handler is not implemented in the SDK Dear @nxp16 ,
No. A peripheral error occurring while using DMA does not necessarily mean that the DMA controller itself will report an error. In most cases, SPI errors and DMA errors are handled by two separate status and interrupt mechanisms.
DMA reports only DMA-, bus-, or transfer-layer errors. Protocol-level or FIFO-related errors in LPSPI should be handled through the LPSPI peripheral's own status flags and error interrupts. Operating in DMA mode does not automatically convert all SPI errors into DMA errors.
Best Regards,
Shelly Zhang Re: IMXRT EDMA error IRQ handler is not implemented in the SDK Dear @nxp16 ,
I understand your concern, and I agree that handling peripheral error conditions separately from the SDK transfer API can increase the amount of application-level code required. Thank you for the feedback. I will pass your comments to the SDK team.
Best Regards,
Shelly Zhang Re: IMXRT EDMA error IRQ handler is not implemented in the SDK Actually, it's worse than I thought. Using the EDMA LPSPI transfer API makes it impossible to catch SPI errors because the function that LPSPI_MasterTransferEDMA calls, LPSPI_PrepareTransferEDMA. disables ALL SPI interrupts. So it's impossible to enable the error interrupts before calling it, because it disables them again, and it's too late afterward because the SPI EDMA transfer is already taking place. This is a major bug in this API. -m Re: IMXRT EDMA error IRQ handler is not implemented in the SDK Yes, that is exactly what I had to do for now as a workaround. However, editing the SDK files is not really a good solution, as they can change on update of the SDK unfortunately. Thanks, -m Re: IMXRT EDMA error IRQ handler is not implemented in the SDK Dear @nxp16 ,
Thank you for pointing this out.
I checked the implementation of LPSPI_PrepareTransferEDMA(LPSPI_Type *base), and I do see that it calls LPSPI_DisableInterrupts(base, (uint32_t)kLPSPI_AllInterruptEnable):
As a workaround, you may consider modifying this section of the driver so that it does not disable the Transmit Error Interrupt and Receive Error Interrupt. In other words, instead of disabling kLPSPI_AllInterruptEnable , only disable the interrupts that are required for the EDMA transfer operation while keeping the error interrupts enabled.
You can try removing LPSPI_IER_TEIE_MASK and LPSPI_IER_REIE_MASK.
View full article