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.

What difference is between UART functions UART_writePolling() and UART_write()?

Hi,

I am learning to use UART driver from RTOS C:\ti\tirtos_tivac_2_14_00_10 for Tiva-C TM4C1294. Even after reading the doc file, see below please, I don't see their difference. Could you explain it to me?

Thanks,

int UART_write ( UART_Handle  handle,
const void *  buffer,
size_t  size 
)

Function that writes data to a UART with interrupt enabled. This API must be used mutually exclusive with UART_writePolling().

In UART_MODE_BLOCKING, UART_write will block task execution until all the data in buffer has been written.

int UART_writePolling ( UART_Handle  handle,
const void *  buffer,
size_t  size 
)

Function that writes data to a UART without interrupts. This API must be used mutually exclusive with UART_write().

This function initiates an operation to write data to a UART controller.

UART_writePolling will not return until all the data was written to the UART (or its FIFO if applicable).

  • Hi Robert,


    UART_writePolling() (assigned to UARTTivaDMA_writePolling on Tiva, in file UARTTivaDMA.c) calls the TivaWare API UARTCharPut(), continuously, in a while loop, writing a single character per loop iteration.  This function does not yield execution to other Tasks, it loops until all data has been transferred (hence the polling name).  This polling style will "hog" the CPU until the transfer is complete.

    UART_write() (assigned to UARTTivaDMA_write on Tiva, in file UARTTivaDMA.c) uses TivaWare APIs to set up the write of the given buffer as a DMA transaction.  The function yields by means of calling Semaphore_pend().  This allows other Tasks in the system to run while the DMA is making the transfer in the background.  Once the transfer is complete, the Semaphore will post, allowing the Task that called UART_write to unblock and continue.  This won't "hog" the CPU, as other Tasks were allowed to run while the DMA was taking care of the transfer in the background.

    You can find more info on these TivaWare APIs in this document: http://www.ti.com/lit/ug/spmu298a/spmu298a.pdf


    Steve