AnsweredAssumed Answered

UART_SendEDMA sends only one byte

Question asked by Rodrigo Martins on Dec 22, 2017
Latest reply on Jan 9, 2018 by Rodrigo Martins

I'm using a MK60DN512VLL10 in a project with KSDK 2.0 and MCUXpresso 10.1.

 

My first attempt was a interrupt mode with ringbuffer, but I was getting RxHardwareOverrun with some frequency. Now I'm trying to use DMA. That's the code:

    //Init UART

    uart_config_t uart_cfg;
    UART_GetDefaultConfig(&uart_cfg);
    uart_cfg.baudRate_Bps = baudrate;
    uart_cfg.parityMode = parity;
    uart_cfg.enableRx = true;
    uart_cfg.enableTx = true;
    uart_cfg.rxFifoWatermark = 1;
    uart_cfg.txFifoWatermark = 1;
    UART_Init(UART4, &uart_cfg, srcClock_Hz);

    // Set up the DMA
    DMAMUX_Init(DMAMUX0);
    DMAMUX_SetSource(DMAMUX0, 1, kDmaRequestMux0UART4Tx);
    DMAMUX_EnableChannel(DMAMUX0, 1);
    DMAMUX_SetSource(DMAMUX0, 0, kDmaRequestMux0UART4Rx);
    DMAMUX_EnableChannel(DMAMUX0, 0);

    edma_config_t dma_cfg;
    EDMA_GetDefaultConfig(&dma_cfg);
    EDMA_Init(DMA0, &dma_cfg);

    // Create EDMA handle.
    EDMA_CreateHandle(&g_RxDmaHandle, DMA0, 0);
    EDMA_CreateHandle(&g_TxDmaHandle, DMA0, 1);
    UART_TransferCreateHandleEDMA(UART4, &g_uartDmaHandle, UART_UserCallback, NULL, &g_TxDmaHandle, &g_RxDmaHandle);

...

     //Send message

    sendXfer.data = txBuffer;
    sendXfer.dataSize = txsize;
    txFinished = 0;
    if(UART_SendEDMA(HMI_UART, &g_uartDmaHandle, &sendXfer) != kStatus_Success)
        return 0;
    return 1;

 

...

//UART Callback

void UART_UserCallback(UART_Type *base, uart_edma_handle_t *handle, status_t status, void *userData)
{
    userData = userData;
    if (kStatus_UART_TxIdle == status)
    {
        txFinished = 1;
    }
    else if (kStatus_UART_RxIdle == status)
    {
        rxFinished = 1;
    }

}

 

The problem is that is send only the first byte of the message.

Outcomes