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.

TM4C129XNCZAD: Uart communication

Part Number: TM4C129XNCZAD

Dear Sir,

I am sending data over the UART.  float Disp_array[37] is float array

Below  line is used for sending data 

UARTSend((char*)&Disp_array, sizeof(Disp_array));

Disp_array is float array. But i am getting only 17 byte on receiver side i.e terminal

Where as   using below modified code   I am getting the all bytes on the receiver i.e terminal

for(count_number=0;count_number<37;count_number++)
{
UARTSend((char*)&Disp_array[count_number], sizeof(Disp_array[count_number]));
for (x=0;x<=20000;x++);
}

The below is the array 

void UARTSend(const unsigned char *pucBuffer, unsigned long ulCount)
{
// Loop while there are more characters to send.
while(ulCount--)
{
MAP_UARTCharPutNonBlocking(UART3_BASE, *pucBuffer++); // Write the next character to the UART.
}
}

Why simple  UARTSend((char*)&Disp_array, sizeof(Disp_array)); is not working?

  • Hi,

      Please change the UARTSend to use ROM_UARTCharPut() instead of ROM_UARTCharPutNonBlocking(). I tried it and it works for me. 

    void
    UARTSend(const uint8_t *pui8Buffer, uint32_t ui32Count)
    {
    //
    // Loop while there are more characters to send.
    //
    while(ui32Count--)
    {
    //
    // Write the next character to the UART.
    //
    ROM_UARTCharPut(UART0_BASE, *pui8Buffer++);
    }
    }

    If you want to use UARTCharPutNonBlocking then you need to check if the return value is true. What happened is that there is no more space in the FIFO when you try to write 37x4=148 bytes of data to the FIFO without waiting for the data to transmit out successfully. Using UARTCharPut guarantees that the function will wait until there is available space in the FIFO before writing. Check the Peripheral Driver user's guide for detail. 

    30.2.2.10 UARTCharPutNonBlocking
    Sends a character to the specified port.
    Prototype:
    bool
    UARTCharPutNonBlocking(uint32_t ui32Base,
    unsigned char ucData)
    Parameters:
    ui32Base is the base address of the UART port.
    ucData is the character to be transmitted.
    Description:
    This function writes the character ucData to the transmit FIFO for the specified port. This
    function does not block, so if there is no space available, then a false is returned and the
    application must retry the function later.
    Returns:
    Returns true if the character was successfully placed in the transmit FIFO or false if there was
    no space available in the transmit FIFO.