[SOLVED] USART DMA not receving data with embOS

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] USART DMA not receving data with embOS

    Hi, I am trying to integrate my code with embOS for ARM. I am trying to send and receive data through usart using DMA. When i run code with out integrating with embOS it is working fine for both Tx & Rx. After integrating with embOS Tx is working fine and DMA Rx is not receiving data but usart RHR is getting value.

    USART is configured for normal mode, baud rate is 9600, parity - None, stop bits - 1.


    Thanks & Regards.
    Santhosh


    DMA settings and recevie code is given below.

    static void _ConfigureDma( void )
    {
    uint32_t dwCfg;
    uint8_t iController;
    /* Driver initialize */
    DMAD_Initialize( &dmad, 0 );
    /* IRQ configure */
    IRQ_ConfigureIT(ID_DMAC0, 0, ISR_DMA);
    IRQ_EnableIT(ID_DMAC0);
    /* Allocate DMA channels for USART */
    usartDmaTxChannel = DMAD_AllocateChannel( &dmad,
    DMAD_TRANSFER_MEMORY, ID_USART);
    usartDmaRxChannel = DMAD_AllocateChannel( &dmad,
    ID_USART, DMAD_TRANSFER_MEMORY);
    if ( usartDmaTxChannel == DMAD_ALLOC_FAILED
    || usartDmaRxChannel == DMAD_ALLOC_FAILED )
    {
    printf("DMA channel allocat error\n\r");
    while(1);
    }
    /* Set RX callback */
    DMAD_SetCallback(&dmad, usartDmaRxChannel,
    (DmadTransferCallback)_DmaRxCallback, 0);
    /* Configure DMA RX channel */
    iController = (usartDmaRxChannel >> 8);
    dwCfg = 0
    | DMAC_CFG_SRC_PER(
    DMAIF_Get_ChannelNumber( iController, ID_USART, DMAD_TRANSFER_RX ))
    | DMAC_CFG_SRC_H2SEL
    | DMAC_CFG_SOD
    | DMAC_CFG_FIFOCFG_ALAP_CFG;
    DMAD_PrepareChannel( &dmad, usartDmaRxChannel, dwCfg );
    /* Configure DMA TX channel */
    iController = (usartDmaTxChannel >> 8);
    dwCfg = 0
    | DMAC_CFG_DST_PER(
    DMAIF_Get_ChannelNumber( iController, ID_USART, DMAD_TRANSFER_TX ))
    | DMAC_CFG_DST_H2SEL
    | DMAC_CFG_SOD
    | DMAC_CFG_FIFOCFG_ALAP_CFG;
    DMAD_PrepareChannel( &dmad, usartDmaTxChannel, dwCfg );
    }


    static void _DmaRx( void )
    {
    sDmaTransferDescriptor td;
    td.dwSrcAddr = (uint32_t)&USART->US_RHR;
    td.dwDstAddr = (uint32_t) pBuffer;
    td.dwCtrlA = BUFFER_SIZE | DMAC_CTRLA_SRC_WIDTH_BYTE | DMAC_CTRLA_DST_WIDTH_BYTE;
    td.dwCtrlB = DMAC_CTRLB_SRC_DSCR | DMAC_CTRLB_DST_DSCR
    | DMAC_CTRLB_SIF_AHB_IF2 | DMAC_CTRLB_DIF_AHB_IF0
    | DMAC_CTRLB_FC_PER2MEM_DMA_FC
    | DMAC_CTRLB_SRC_INCR_FIXED
    | DMAC_CTRLB_DST_INCR_INCREMENTING;
    td.dwDscAddr = 0;
    DMAD_PrepareSingleTransfer(&dmad, usartDmaRxChannel, &td);
    DMAD_StartTransfer(&dmad, usartDmaRxChannel);
    }

    The post was edited 1 time, last by SANTHOSH KUMAR ().

  • Hello Santhosh,

    I don't know which device you are actually using but it should work the same with embOS.
    embOS does not have any influence on your DMA or Uart.
    IRQ interrupts are handled via embOS with a low level interrupt handler in assembler and a high level interrupt handler in your RTOSInit.c.
    Could you please check your MMU table in the RTOSInit.c?
    It defines which memory regions are cached.
    That could be an issue because the DMA writes directly to the memory and you are maybe just reading old data from the cache.
    In this case you would need to invalidate that memory region in the cache.

    If you like you can contact us per email (you'll find the embOS support email address in the embOS manual in chapter "Support") and we'll have a look in your project.
    Maybe we can find something obvious.

    Best regards,
    Til
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.