This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP432P401R: Has anybody working example of DMA UART RX part?

Part Number: MSP432P401R

Hello community,

I can create the running DMA UART sending. unfortunately for DMA UART RX code doesnt work..

Has anybody working example..

Just a couple of my functions...

void prepareDMA()
{
    MAP_DMA_enableModule();
    MAP_DMA_setControlBase(dmaControlTable);
    /* Assign DMA channel 0 to EUSCI_A0_TX0 */
    MAP_DMA_assignChannel(DMA_CH0_EUSCIA0TX);

    /* Setup the TX transfer characteristics & buffers */
    MAP_DMA_setChannelControl(DMA_CH0_EUSCIA0TX | UDMA_PRI_SELECT,
    UDMA_SIZE_8 | UDMA_SRC_INC_8 | UDMA_DST_INC_NONE | UDMA_ARB_1);
    MAP_DMA_assignInterrupt(INT_DMA_INT1, DMA_CHANNEL_0);
    MAP_DMA_disableInterrupt(INT_DMA_INT1);

    /* Assign DMA channel 1 to EUSCI_A0_RX0 */
    MAP_DMA_assignChannel(DMA_CH1_EUSCIA0RX);
    /* Setup the RX transfer characteristics & buffers */
    MAP_DMA_setChannelControl(DMA_CH1_EUSCIA0RX | UDMA_PRI_SELECT,
                              UDMA_SIZE_8 | UDMA_SRC_INC_NONE | UDMA_DST_INC_8 | UDMA_ARB_1);
    MAP_DMA_assignInterrupt(INT_DMA_INT2, DMA_CHANNEL_1);
    MAP_DMA_disableInterrupt(INT_DMA_INT2);
}

void UART_send_dma(char buff[], int n)
{
    MAP_DMA_setChannelTransfer(
            DMA_CH0_EUSCIA0TX | UDMA_PRI_SELECT,
            UDMA_MODE_BASIC,
            buff,
            (void *) MAP_SPI_getTransmitBufferAddressForDMA(EUSCI_A0_BASE), n);

    MAP_DMA_enableInterrupt(INT_DMA_INT1);
    MAP_DMA_enableInterrupt(INT_DMA_ERR);
    MAP_DMA_enableChannel(DMA_CHANNEL_0 );
}

void UART_receive_dma(char buff[], int n)
{
    MAP_DMA_setChannelTransfer(
            DMA_CH1_EUSCIA0RX | UDMA_PRI_SELECT,
            UDMA_MODE_BASIC,
            (void*)MAP_SPI_getReceiveBufferAddressForDMA(EUSCI_A0_BASE),
            buff, n);
    MAP_DMA_enableInterrupt(INT_DMA_INT2);
    MAP_DMA_enableInterrupt(INT_DMA_ERR);
    MAP_DMA_enableChannel(DMA_CHANNEL_1);
}

unfortunately after UART_receive_dma() call there is no related interrupt...
UART_send_dma() works, every call resulted in interrupt call..

Thanks 

 

  • Yuliy,
    When the eUSCI peripheral is released from reset the TX IFG is automatically set indicating that the transmit buffer is empty and another byte can be written to the buffer. This is not the case in the receive. The 2nd DMA irq assigned to the channel 1 (DMA_CH1_EUSCIA0RX) will not happen until 'n' bytes have been received. If you have a loop back of some kind you need to make sure that the Rx is called before the Tx otherwise the Tx will transmit bytes before the Rx is ready and the Rx irq will not happen because it did not see all n bytes. I would recommend using separate transmit and receive buffers.

    If you navigate to the UART portion of the API guide you will also find specific APIs instead of using the SPI APIs.

    dev.ti.com/.../modules.html

    Regards,
    Chris
  • >If you have a loop back of some kind..

    No, I have not.. the input stream (RX, from my point of view) is generated from independent source.

    Just once a second 256 byte UART send.

    >If you navigate to the UART portion of the API guide you will also find specific APIs instead of using the SPI APIs. 

    Thanks, will do it later today.

    Back to my question, so from your point of view, my functions are right in coding?

    All I have to pay attention is to have inbound UART stream, right?

  • Yuliy,
    Yes, I believe that the functions are coded correctly. Typically, I have seen the configuration of the DMA done once and then updated as needed to repeat the data transfer. So while I am not used to seeing the DMA configured like this, I still do not see any issue as long as you pay attention to the UART inbound stream as you mention.

    Chris
  • Okay.

    I can run this DMA RX with bare metal code, but cannot run this in TI RTos..

    Of course, I know that in TI RTOS there are no irq but hwi's..

    Nevertheless, do not have time to investigate it further

    Thank you.

    let us close the case.

**Attention** This is a public forum