[i.MX8M Plus] Cortex-M7 ECSPI Master + SDMA: fails in highspeed. Hi all, I am running FreeRTOS on the Cortex-M7 of an i.MX8M Plus and trying to use ECSPI1 in Master Mode with SDMA to read an ADC at high speeds (20 MHz to 40 MHz). The communication works perfectly at 10 MHz. However, when increasing the baud rate to 20 MHz or 40 MHz, the transfer hangs. I've already configured the rootclock to 160MHz. Is it actually feasible to run ECSPI + SDMA on the M7 core at 40 MHz on this SoC? Communication & Control(I3C | I2C | SPI | FlexCAN | Ethernet | FlexIO) Re: [i.MX8M Plus] Cortex-M7 ECSPI Master + SDMA: fails in highspeed. Hi all, I am running FreeRTOS on the Cortex-M7 of an i.MX8M Plus and using ECSPI1 in master mode with SDMA to read data from an external ADC at high speeds. Communication is completely stable at 10 MHz, but when I increase the SPI clock to 20 MHz or 40 MHz, the transfer consistently hangs. The root clock has already been configured to 160 MHz, so the clock source itself does not appear to be the limitation. This raises the question of whether ECSPI combined with SDMA on the M7 core can reliably sustain SPI operation at 40 MHz on this SoC, or if there are architectural, SDMA, or ECSPI hardware constraints that effectively limit the maximum usable SPI frequency in this configuration. transunioncredit.com Re: [i.MX8M Plus] Cortex-M7 ECSPI Master + SDMA: fails in highspeed. Hi @RafaelFernandes
Which SDMA do you use for ECSPI? Please share your code patch.
B.R Re: [i.MX8M Plus] Cortex-M7 ECSPI Master + SDMA: fails in highspeed. I'm sorry for the delay — I had forgotten this issue was still open. I tested a patch on my side and this is the code I am currently using: AT_NONCACHEABLE_SECTION_ALIGN(sdma_handle_t tx_handle, 4); AT_NONCACHEABLE_SECTION_ALIGN(sdma_handle_t rx_handle, 4); AT_NONCACHEABLE_SECTION_ALIGN(sdma_context_data_t context_tx, 4); AT_NONCACHEABLE_SECTION_ALIGN(sdma_context_data_t context_rx, 4); AT_NONCACHEABLE_SECTION_ALIGN(ecspi_sdma_handle_t ecspi_sdma_handle, 4); AT_NONCACHEABLE_SECTION_ALIGN(uint32_t rx[8], 4); volatile bool completed = false; void callback_ecspi_sdma(ECSPI_Type *base, ecspi_sdma_handle_t *handle, status_t status, void *userData) { completed = true; } #define SPI_SDMA SDMAARM1 #define TX_CHANNEL 2U #define RX_CHANNEL 1U int main(void) { sdma_config_t sdma_config; BOARD_InitHardware(); SDMA_GetDefaultConfig(&sdma_config); SDMA_Init(SPI_SDMA, &sdma_config); SDMA_CreateHandle(&tx_handle, SPI_SDMA, TX_CHANNEL, &context_tx); SDMA_SetChannelPriority(SPI_SDMA, TX_CHANNEL, 3); SDMA_CreateHandle(&rx_handle, SPI_SDMA, RX_CHANNEL, &context_rx); SDMA_SetChannelPriority(SPI_SDMA, RX_CHANNEL, 2); ECSPI_MasterTransferCreateHandleSDMA( ECSPI1, &ecspi_sdma_handle, callback_ecspi_sdma, NULL, &tx_handle, &rx_handle, 2, 1, TX_CHANNEL, RX_CHANNEL); ecspi_master_config_t config; ECSPI_MasterGetDefaultConfig(&config); config.baudRate_Bps = 1000000; config.burstLength = 8; PRINTF("INITIATING...\r\n"); ECSPI_MasterInit( ECSPI1, &config, CLOCK_GetClockRootFreq(kCLOCK_RootEcspi1)); ecspi_transfer_t xfer; xfer.channel = kECSPI_Channel0; xfer.dataSize = 1; xfer.rxData = &rx[0]; xfer.txData = NULL; if (ECSPI_MasterTransferSDMA(ECSPI1, &ecspi_sdma_handle, &xfer) != kStatus_Success) { PRINTF("Transfer failed\r\n"); } while (!completed) { } PRINTF("ENDED\r\n"); while (1) { } } However, I am still facing the same issue when using fsl_ecspi_sdma: the transfer does not even start. I monitored the ECSPI clock line with an oscilloscope and there is no activity at all, which suggests the peripheral is never beginning the transaction. I tried to follow the sai_sdma example as a reference when building this code, adapting the same initialization flow and SDMA handle usage for ECSPI. Could my issue be related to incorrect SDMA event mapping or poor channel selection for ECSPI1 TX/RX? Also, it would be awesome if there were an official ecspi_sdma example project in the SDK, since it would make validating the required configuration much easier. Any guidance would be greatly appreciated. Re: [i.MX8M Plus] Cortex-M7 ECSPI Master + SDMA: fails in highspeed. I think I should have tagged you @pengyong_zhang. I'm sorry. Re: [i.MX8M Plus] Cortex-M7 ECSPI Master + SDMA: fails in highspeed. Hi @RafaelFernandes
Sorry to reply late, i received your message, and will give you the answer ASAP.
B.R Re: [i.MX8M Plus] Cortex-M7 ECSPI Master + SDMA: fails in highspeed. Hi @RafaelFernandes
From imx8mp datasheet, The maximum ECSPI1 Master Read and Write frequencies(In theory) are as follows:
But in reality, it doesn't reach that high a speed. Have you tried other lower frequencies? For example, 15 MHz?
B.R
View full article