2374437_en-US

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

2374437_en-US

2374437_en-US

How to increase the ECSPI of imx8mmini baud rate to 52Mbps?

hi  

     For the M4 core of i.MX8M Mini, using the ECSPI peripheral with SDMA to read data at a rate of 32 Mbps (the datasheet says the maximum ECSPI rate is 52 Mbps), the example used is "SDK_2.5.0/boards/evkmimx8mm/cmsis_driver_examples/ecspi/sdma_loopback_transfer". However, this example reinitializes both SPI and DMA for each data read, wasting a lot of time. Which functions and statements do not need to be reinitialized in the ECSPI_MasterTransferSDMA function? Also, I have increased the clock frequency, but the issue remains the same.now my code below:

 
status_t ECSPI_MasterTransferSDMA(ECSPI_Type *base, ecspi_sdma_handle_t *handle, ecspi_transfer_t *xfer)
{
//    assert(base && handle && xfer);
 
//    sdma_transfer_config_t xferConfig = {0U};
//    sdma_peripheral_t perType = kSDMA_PeripheralNormal;
 
    /* Check if ECSPI is busy */
    if (handle->state == kECSPI_Busy)
    {
        return kStatus_ECSPI_Busy;
    }
 
    /* Check if the input arguments valid */
    if (((xfer->txData == NULL) && (xfer->rxData == NULL)) || (xfer->dataSize == 0U))
    {
        return kStatus_InvalidArgument;
    }
// if(test_init_flg == 0)
{
    ECSPI_Enable(base, true);
}
handle->state = kECSPI_Busy;
if(test_init_flg == 0)
{
 
    ECSPI_SetChannelSelect(base, xfer->channel);
}
#if defined(FSL_FEATURE_SOC_SPBA_COUNT) && (FSL_FEATURE_SOC_SPBA_COUNT > 0)
if(test_init_flg == 0)
{
 
    bool isSpba = SDMA_IsPeripheralInSPBA((uint32_t)base);
    /* Judge if the instance is located in SPBA */
    if (isSpba)
    {
        perType = kSDMA_PeripheralNormal_SP;
    }
}
#endif /* FSL_FEATURE_SOC_SPBA_COUNT */
if(test_init_flg == 0)
{
 
    /* Prepare transfer. */
    SDMA_PrepareTransfer(&xferConfig, (uint32_t)xfer->txData, (uint32_t) & (base->TXDATA), sizeof(uint8_t),
                         sizeof(uint8_t), sizeof(uint8_t), xfer->dataSize, handle->txSdmaHandle->eventSource, perType,
                         kSDMA_MemoryToPeripheral);
}
    /* Submit transfer. */
    SDMA_SubmitTransfer(handle->txSdmaHandle, &xferConfig);
 
if(test_init_flg == 0)
{
    /* Prepare transfer. */
    SDMA_PrepareTransfer(&xferConfig2, (uint32_t) & (base->RXDATA), (uint32_t)xfer->rxData, sizeof(uint8_t),
                         sizeof(uint8_t), sizeof(uint8_t), xfer->dataSize, handle->rxSdmaHandle->eventSource, perType,
                         kSDMA_PeripheralToMemory);
}
    /* Submit transfer. */
    SDMA_SubmitTransfer(handle->rxSdmaHandle, &xferConfig2);
    /* Start Rx transfer */
    handle->rxInProgress = true;
    SDMA_StartTransfer(handle->rxSdmaHandle);
    ECSPI_EnableDMA(base, kECSPI_RxDmaEnable, true);
 
    /* Start Tx transfer */
    handle->txInProgress = true;
    SDMA_StartTransfer(handle->txSdmaHandle);
    ECSPI_EnableDMA(base, kECSPI_TxDmaEnable, true);
test_init_flg=1;
 
    return kStatus_Success;
}

void main(void)

{

...

while(1)
{
 
    DRIVER_MASTER_SPI.Transfer(masterTxData, masterRxData, TRANSFER_SIZE);//call ECSPI_MasterTransferSDMA
 
    /* Wait slave received all data. */
    while (!isTransferCompleted)
    {
    }
    ...
}

}

 

sofia_0571_0-1780311681503.png
回复: How to increase the ECSPI of imx8mmini baud rate to 52Mbps?

attach source code

Re: How to increase the ECSPI of imx8mmini baud rate to 52Mbps?

Hello @sofia_0571 

Hope you are doing very well.


You can try instead of bypassing the setup using a flag inside the function, keep ECSPI_MasterTransferSDMA purely for your high-speed loop by stripping out the heavy lifting. Create a "Fast Trigger" function that assumes preparation is already complete.


Something like:

status_t ECSPI_MasterTransferSDMA_FastTrigger(ECSPI_Type *base, ecspi_sdma_handle_t *handle, uint32_t size)
{
    handle->state = kECSPI_Busy;

    xferConfig.dataSize = size;
    xferConfig2.dataSize = size;
    
    SDMA_SubmitTransfer(handle->txSdmaHandle, &xferConfig);
    SDMA_SubmitTransfer(handle->rxSdmaHandle, &xferConfig2);

    handle->rxInProgress = true;
    SDMA_StartTransfer(handle->rxSdmaHandle);
    ECSPI_EnableDMA(base, kECSPI_RxDmaEnable, true);

    handle->txInProgress = true;
    SDMA_StartTransfer(handle->txSdmaHandle);
    ECSPI_EnableDMA(base, kECSPI_TxDmaEnable, true);

    return kStatus_Success;
}

Best regards,

Salas.

タグ(1)
評価なし
バージョン履歴
最終更新日:
18 時間前
更新者: