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.

CC2340R5: Questions about UART & DMA

hello everyone,

How can I configure the DMA to send data without using the function uart2_open()?

Currently I configure my own UART read callback without uart2_open(), so I don't use the DMA. The reason is as follows:

I'm trying to use the CC2340 UART for LIN communication. I need to use the read callback to complete the reception of the LIN message.

There is an example uart2callback which is provided in SDK 7.10, but the read callback has a delay due to the DMA enabled in the function uart2_open().

This delay P0 is terrible for LIN communication.

In LIN communication I only need to receive 1 Byte, so I don't need DMA and FIFO, but their enable causes delay with Receiving. 

However, with the function HwiP_create() I successfully configured a UART read callback without DMA and FIFO. It works good and no long receive delays.

For UART transmit, there is a function UARTPutChar() in SDK 7.10. (Path: simplelink_lowpower_f3_sdk_7_20_00_01_eng\source\ti\devices\cc23x0r5\driverlib)

//*****************************************************************************
//
// Blocks until there is space in the data register, and writes a byte to it
//
//*****************************************************************************
void UARTPutChar(uint32_t base, uint8_t data)
{
    // Wait until space is available.
    while (HWREG(base + UART_O_FR) & UART_FR_TXFF) {}

    // Send the char.
    HWREG(base + UART_O_DR) = data;
}

Very weirdly my code has gotten stuck in this while loop, 2 times.

I never found out why and am very afraid of this happening again. 

So is it possible to configure the UART transmit separately as DMA transmit and not use the function uart2_open()?

Is there any info available?

Thank you

Best Regards,

Peter

  • Hello Peter,

    To give some context into the UART2 and DMA read from the UART2.h header:

    “UART2 uses DMA to transfer data between the UART FIFOs and the RX and TX ring buffers (in nonblocking mode). In blocking mode and callback mode, DMA will transfer data straight between the hardware FIFO and the source/destination buffer supplied by the application.”

    When using TI Drivers the UART2 is linked to DMA which does not suit your application, so in order to use UART without DMA capabilities you will need to extract the UART functionality from the UART2 TI Driver to create your own driverlib-operated application; in the end you should not be using UART2 TI Driver APIs when you do not want UART2-DMA linked together.

    Thanks
    Alex F

  • hi Alex,

    Thanks for the info. 

    I was wondering if it was possible to connect the UART Tx to the DMA alone, while the UART Rx continues to use the hardware interrupts I configured in callback mode :)

    BR,

    Peter

  • Hello Peter,

    For insight of how DMA is interlinked with UART2 I would recommend visiting (simplelink_cc13xx_cc26xx_sdk_7_10_01_24\source\ti\drivers\uart2\UART2CC26X2.c), from the UART2CC26X2.c file we can see that the TX and RX are directly linked to the DMA for UART operation. 

    If you are trying to use the UART RX without DMA/UART2 TI driver then you would also not be able to use DMA/UART2 TI driver for UART TX; however, it would be possible to implement UART TX with DMA with your own independent driverlib functions (using the UART2CC26X2.c as reference), but it would be up to you to accomplish this functionality if you pursue that path. 

    Thanks,
    Alex F

  • Thank you Alex, your help is much appreciated.