LPSPI3 + eDMA4 Transfer Issue on i.MX93 EVK (M33 Core)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPSPI3 + eDMA4 Transfer Issue on i.MX93 EVK (M33 Core)

973 Views
KyeJeong
Contributor II

Hello,

I am currently testing an external ADC (ADS131E08) functionality using the i.MX93 EVK. I have already confirmed that the LPSPI3 interface works fine in Polling/Interrupt mode. Now, I am trying to implement LPSPI3 combined with eDMA4 to optimize performance.

Environment:

Target Board: MCIMX93-EVK (Cortex-M33)

SDK Version: MCUXpresso SDK 25.12.0

IDE: VSCode with MCUXpresso Extension

Since there is no specific "LPSPI-EDMA" example for i.MX93 in the SDK, I implemented the following based on other peripheral examples:

 

1. Memory Allocation (OCRAM - NonCacheable)

I placed all DMA-related buffers and handles in the OCRAM section and configured the MPU as Non-Cacheable to avoid coherency issues.

============================ code ===============================

/* Linker Script */ MEMORY { m_data (RW) : ORIGIN = 0x20003000, LENGTH = 0x0001B000 m_ocram (RW) : ORIGIN = 0x20480000, LENGTH = 0x00040000 } .noncacheable_section : { . = ALIGN(32); __noncacheable_start__ = .; *(NonCacheable) __noncacheable_end__ = .; } > m_ocram

/* Variable Definitions */ __attribute__((section("NonCacheable"), aligned(32))) static lpspi_master_edma_handle_t g_lpspi_master_edma_handle; AT_NONCACHEABLE_SECTION_INIT(static edma_handle_t g_lpspi_tx_dma_handle); AT_NONCACHEABLE_SECTION_INIT(static edma_handle_t g_lpspi_rx_dma_handle); __attribute__((section("NonCacheable"), aligned(32))) static uint8_t dummy_tx_data[ADC_SAMPLE_BYTES] = { ... }; __attribute__((section("NonCacheable"), aligned(32))) static uint8_t sample_buf_ping[INTERPOLATION_L][ADC_SAMPLE_BYTES];

============================ code ===============================

 

2. Initialization Process

I configured eDMA4, created handles, and linked them to LPSPI3.

============================ code ===============================

static void LPSPI_Master_DMA_Init(void) { edma_config_t userConfig; EDMA_GetDefaultConfig(&userConfig); EDMA_Init(DMA4, &userConfig); EDMA_CreateHandle(&g_lpspi_tx_dma_handle, DMA4, LPSPI3_TX_DMA_CHANNEL); // CH 12 EDMA_CreateHandle(&g_lpspi_rx_dma_handle, DMA4, LPSPI3_RX_DMA_CHANNEL); // CH 13 EDMA_SetChannelMux(DMA4, LPSPI3_TX_DMA_CHANNEL, kDma4RequestMuxLPSPI3Tx); EDMA_SetChannelMux(DMA4, LPSPI3_RX_DMA_CHANNEL, kDma4RequestMuxLPSPI3Rx); LPSPI_MasterTransferCreateHandleEDMA( LPSPI3, &g_lpspi_master_edma_handle, LPSPI_MasterUserCallback, NULL, &g_lpspi_rx_dma_handle, &g_lpspi_tx_dma_handle); }

============================ code ===============================

 

3. SPI Transaction with Address Conversion

I used MEMORY_ConvertMemoryMapAddress to provide the System Address (Local2DMA) to the eDMA engine.

============================ code ===============================

xfer.txData = (uint8_t *)MEMORY_ConvertMemoryMapAddress((uint32_t)dummy_tx_data, kMEMORY_Local2DMA); xfer.rxData = (uint8_t *)MEMORY_ConvertMemoryMapAddress((uint32_t)sample_buf_ping, kMEMORY_Local2DMA); xfer.dataSize = ADC_SAMPLE_BYTES; xfer.configFlags = kLPSPI_MasterPcs0; status_t ret = LPSPI_MasterTransferEDMA(LPSPI3, &g_lpspi_master_edma_handle, &xfer);

============================ code ===============================

 

Current Symptoms:

The first call to LPSPI_MasterTransferEDMA returns kStatus_Success, but no SPI clock or data is observed on the oscilloscope.

From the second call onwards, it consistently returns kStatus_LPSPI_Busy. This suggests that the driver's internal state is stuck in 'Busy' because the first transfer never completed or triggered the 'Transfer Done' interrupt.

Checking the eDMA4 registers:

TCD[12].CH_CSR (ERQ bit) is 0 (or not being set properly).

CH_ES (Error Status) sometimes shows DBE (Destination Bus Error).

The LPSPI3 DER register has TDDE and RDDE bits set to 1 after the first call, meaning the SPI peripheral is requesting DMA, but the eDMA engine is not responding.

 

 

0 Kudos
Reply
2 Replies

945 Views
JosephAtNXP
NXP TechSupport
NXP TechSupport

Hi,

Thank you for your interest in NXP Semiconductor products,

You can confirm that you have adjusted the resource assignment, clocks and eDMA config with the following Cortex-M SDK test.

https://community.nxp.com/t5/i-MX-Processors-Knowledge-Base/Test-LPUART2-DSP-domain-EDMA-on-i-MX8ULP...

Regards,

0 Kudos
Reply

927 Views
KyeJeong
Contributor II
Thank you for your quick response.

As you suggested, I attempted to configure the TRDC to enable DMA access. However, since my M33 firmware is running in Non-Secure mode, any attempt to access or modify the TRDC registers results in a HardFault (Bus Error).

Based on this, I have a follow-up question:
Is it mandatory to complete the TRDC peripheral/memory access configurations within the A55 U-Boot (or ATF/SPL) phase before launching the M33 core?

Since the TRDC seems to be locked or restricted for Non-Secure M33 masters, I suspect that the configuration for LPSPI3 and eDMA4 must be pre-defined in the bootloader's TRDC initialization table. Could you confirm if this is the correct architectural approach for i.MX93?
0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2346223%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ELPSPI3%20%2B%20eDMA4%20Transfer%20Issue%20on%20i.MX93%20EVK%20(M33%20Core)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2346223%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3EI%20am%20currently%20testing%20an%20external%20ADC%20(ADS131E08)%20functionality%20using%20the%20i.MX93%20EVK.%20I%20have%20already%20confirmed%20that%20the%20LPSPI3%20interface%20works%20fine%20in%20Polling%2FInterrupt%20mode.%20Now%2C%20I%20am%20trying%20to%20implement%20LPSPI3%20combined%20with%20eDMA4%20to%20optimize%20performance.%3C%2FP%3E%3CP%3EEnvironment%3A%3C%2FP%3E%3CP%3ETarget%20Board%3A%20MCIMX93-EVK%20(Cortex-M33)%3C%2FP%3E%3CP%3ESDK%20Version%3A%20MCUXpresso%20SDK%2025.12.0%3C%2FP%3E%3CP%3EIDE%3A%20VSCode%20with%20MCUXpresso%20Extension%3C%2FP%3E%3CP%3ESince%20there%20is%20no%20specific%20%22LPSPI-EDMA%22%20example%20for%20i.MX93%20in%20the%20SDK%2C%20I%20implemented%20the%20following%20based%20on%20other%20peripheral%20examples%3A%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E1.%20Memory%20Allocation%20(OCRAM%20-%20NonCacheable)%3C%2FP%3E%3CP%3EI%20placed%20all%20DMA-related%20buffers%20and%20handles%20in%20the%20OCRAM%20section%20and%20configured%20the%20MPU%20as%20Non-Cacheable%20to%20avoid%20coherency%20issues.%3C%2FP%3E%3CP%3E%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%20code%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3C%2FP%3E%3CP%3E%2F*%20Linker%20Script%20*%2F%20MEMORY%20%7B%20m_data%20(RW)%20%3A%20ORIGIN%20%3D%200x20003000%2C%20LENGTH%20%3D%200x0001B000%20m_ocram%20(RW)%20%3A%20ORIGIN%20%3D%200x20480000%2C%20LENGTH%20%3D%200x00040000%20%7D%20.noncacheable_section%20%3A%20%7B%20.%20%3D%20ALIGN(32)%3B%20__noncacheable_start__%20%3D%20.%3B%20*(NonCacheable)%20__noncacheable_end__%20%3D%20.%3B%20%7D%20%26gt%3B%20m_ocram%3C%2FP%3E%3CP%3E%2F*%20Variable%20Definitions%20*%2F%20__attribute__((section(%22NonCacheable%22)%2C%20aligned(32)))%20static%20lpspi_master_edma_handle_t%20g_lpspi_master_edma_handle%3B%20AT_NONCACHEABLE_SECTION_INIT(static%20edma_handle_t%20g_lpspi_tx_dma_handle)%3B%20AT_NONCACHEABLE_SECTION_INIT(static%20edma_handle_t%20g_lpspi_rx_dma_handle)%3B%20__attribute__((section(%22NonCacheable%22)%2C%20aligned(32)))%20static%20uint8_t%20dummy_tx_data%5BADC_SAMPLE_BYTES%5D%20%3D%20%7B%20...%20%7D%3B%20__attribute__((section(%22NonCacheable%22)%2C%20aligned(32)))%20static%20uint8_t%20sample_buf_ping%5BINTERPOLATION_L%5D%5BADC_SAMPLE_BYTES%5D%3B%3C%2FP%3E%3CP%3E%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%20code%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E2.%20Initialization%20Process%3C%2FP%3E%3CP%3E%3CSPAN%3EI%20configured%20eDMA4%2C%20created%20handles%2C%20and%20linked%20them%20to%20LPSPI3.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%20code%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3C%2FP%3E%3CP%3Estatic%20void%20LPSPI_Master_DMA_Init(void)%20%7B%20edma_config_t%20userConfig%3B%20EDMA_GetDefaultConfig(%26amp%3BuserConfig)%3B%20EDMA_Init(DMA4%2C%20%26amp%3BuserConfig)%3B%20EDMA_CreateHandle(%26amp%3Bg_lpspi_tx_dma_handle%2C%20DMA4%2C%20LPSPI3_TX_DMA_CHANNEL)%3B%20%2F%2F%20CH%2012%20EDMA_CreateHandle(%26amp%3Bg_lpspi_rx_dma_handle%2C%20DMA4%2C%20LPSPI3_RX_DMA_CHANNEL)%3B%20%2F%2F%20CH%2013%20EDMA_SetChannelMux(DMA4%2C%20LPSPI3_TX_DMA_CHANNEL%2C%20kDma4RequestMuxLPSPI3Tx)%3B%20EDMA_SetChannelMux(DMA4%2C%20LPSPI3_RX_DMA_CHANNEL%2C%20kDma4RequestMuxLPSPI3Rx)%3B%20LPSPI_MasterTransferCreateHandleEDMA(%20LPSPI3%2C%20%26amp%3Bg_lpspi_master_edma_handle%2C%20LPSPI_MasterUserCallback%2C%20NULL%2C%20%26amp%3Bg_lpspi_rx_dma_handle%2C%20%26amp%3Bg_lpspi_tx_dma_handle)%3B%20%7D%3C%2FP%3E%3CP%3E%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%20code%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E3.%20SPI%20Transaction%20with%20Address%20Conversion%3C%2FP%3E%3CP%3EI%20used%20MEMORY_ConvertMemoryMapAddress%20to%20provide%20the%20System%20Address%20(Local2DMA)%20to%20the%20eDMA%20engine.%3C%2FP%3E%3CP%3E%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%20code%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3C%2FP%3E%3CP%3Exfer.txData%20%3D%20(uint8_t%20*)MEMORY_ConvertMemoryMapAddress((uint32_t)dummy_tx_data%2C%20kMEMORY_Local2DMA)%3B%20xfer.rxData%20%3D%20(uint8_t%20*)MEMORY_ConvertMemoryMapAddress((uint32_t)sample_buf_ping%2C%20kMEMORY_Local2DMA)%3B%20xfer.dataSize%20%3D%20ADC_SAMPLE_BYTES%3B%20xfer.configFlags%20%3D%20kLPSPI_MasterPcs0%3B%20status_t%20ret%20%3D%20LPSPI_MasterTransferEDMA(LPSPI3%2C%20%26amp%3Bg_lpspi_master_edma_handle%2C%20%26amp%3Bxfer)%3B%3C%2FP%3E%3CP%3E%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%20code%20%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3C%2FP%3E%3CBR%20%2F%3E%3CP%3ECurrent%20Symptoms%3A%3C%2FP%3E%3CP%3EThe%20first%20call%20to%20LPSPI_MasterTransferEDMA%20returns%20kStatus_Success%2C%20but%20no%20SPI%20clock%20or%20data%20is%20observed%20on%20the%20oscilloscope.%3C%2FP%3E%3CP%3EFrom%20the%20second%20call%20onwards%2C%20it%20consistently%20returns%20kStatus_LPSPI_Busy.%20This%20suggests%20that%20the%20driver's%20internal%20state%20is%20stuck%20in%20'Busy'%20because%20the%20first%20transfer%20never%20completed%20or%20triggered%20the%20'Transfer%20Done'%20interrupt.%3C%2FP%3E%3CP%3EChecking%20the%20eDMA4%20registers%3A%3C%2FP%3E%3CP%3ETCD%5B12%5D.CH_CSR%20(ERQ%20bit)%20is%200%20(or%20not%20being%20set%20properly).%3C%2FP%3E%3CP%3ECH_ES%20(Error%20Status)%20sometimes%20shows%20DBE%20(Destination%20Bus%20Error).%3C%2FP%3E%3CP%3EThe%20LPSPI3%20DER%20register%20has%20TDDE%20and%20RDDE%20bits%20set%20to%201%20after%20the%20first%20call%2C%20meaning%20the%20SPI%20peripheral%20is%20requesting%20DMA%2C%20but%20the%20eDMA%20engine%20is%20not%20responding.%3C%2FP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2346223%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3Ei.MX%208%20Family%20%7C%20i.MX%208QuadMax%20(8QM)%20%7C%208QuadPlus%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Ei.MX%208M%20%7C%20i.MX%208M%20Mini%20%7C%20i.MX%208M%20Nano%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2346633%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20LPSPI3%20%2B%20eDMA4%20Transfer%20Issue%20on%20i.MX93%20EVK%20(M33%20Core)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2346633%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EThank%20you%20for%20your%20quick%20response.%3CBR%20%2F%3E%3CBR%20%2F%3EAs%20you%20suggested%2C%20I%20attempted%20to%20configure%20the%20TRDC%20to%20enable%20DMA%20access.%20However%2C%20since%20my%20M33%20firmware%20is%20running%20in%20Non-Secure%20mode%2C%20any%20attempt%20to%20access%20or%20modify%20the%20TRDC%20registers%20results%20in%20a%20HardFault%20(Bus%20Error).%3CBR%20%2F%3E%3CBR%20%2F%3EBased%20on%20this%2C%20I%20have%20a%20follow-up%20question%3A%3CBR%20%2F%3EIs%20it%20mandatory%20to%20complete%20the%20TRDC%20peripheral%2Fmemory%20access%20configurations%20within%20the%20A55%20U-Boot%20(or%20ATF%2FSPL)%20phase%20before%20launching%20the%20M33%20core%3F%3CBR%20%2F%3E%3CBR%20%2F%3ESince%20the%20TRDC%20seems%20to%20be%20locked%20or%20restricted%20for%20Non-Secure%20M33%20masters%2C%20I%20suspect%20that%20the%20configuration%20for%20LPSPI3%20and%20eDMA4%20must%20be%20pre-defined%20in%20the%20bootloader's%20TRDC%20initialization%20table.%20Could%20you%20confirm%20if%20this%20is%20the%20correct%20architectural%20approach%20for%20i.MX93%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2346505%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20LPSPI3%20%2B%20eDMA4%20Transfer%20Issue%20on%20i.MX93%20EVK%20(M33%20Core)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2346505%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3C%2FP%3E%0A%3CP%3EThank%20you%20for%20your%20interest%20in%20NXP%20Semiconductor%20products%2C%3C%2FP%3E%0A%3CP%3EYou%20can%20confirm%20that%20you%20have%20adjusted%20the%20resource%20assignment%2C%20clocks%20and%20eDMA%20config%20with%20the%20following%20Cortex-M%20SDK%20test.%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fi-MX-Processors-Knowledge-Base%2FTest-LPUART2-DSP-domain-EDMA-on-i-MX8ULP-M33%2Fta-p%2F2084403%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fi-MX-Processors-Knowledge-Base%2FTest-LPUART2-DSP-domain-EDMA-on-i-MX8ULP-M33%2Fta-p%2F2084403%3C%2FA%3E%3C%2FP%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%3C%2FLINGO-BODY%3E