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.

TM4C1294NCPDT: UART BEGINNER QUESTION for UART_ECHO example

Part Number: TM4C1294NCPDT

Hi there,

I am currently working on the UART_Echo example given by Tivac. I am wondering what does the code highlighted in red do? I know that it calls to a function that links to cost uint8_t *pui8buffer which is a type of pointer for a ringbuffer. May if i anyone can shed some light or point me a direction where i can learn more about what it does? 

Another question that is related will be why do we need put this "\033[2J" in front of Hello Text

void
UARTSend(const uint8_t *pui8Buffer, uint32_t ui32Count)

Question:

UARTSend((uint8_t *)"\033[2JHello text: ", 16);

  • The (uint8_t *) simply casts the string from being unsigned char to uint8_t. (Not all uint8_t are ring buffers.) The \033[2J is an escape sequence that is used to do a clear screen before typing "Hello text".

  • Hello,

    Vendor's Bob has beat our crack crüe to the punch.   Again!

    While we agree w/his assessment it should be noted that (almost) all professions (even hobbies) most always employ, "Unique jargon, idioms - even vocabulary!")    It is this (uniqueness) which led to your question - and my small tech group believes your "active pursuit" of understanding (rather than "blind acceptance") is to be commended!    Good job.

    You may further explore, "ANSI Escape Sequences" (Google hits will "over-flow" your page) and prepare you for (even) "future ANSI meetings."    And - BTW - crack staff advises that the 'mystery \033' is the "Octal encoding of the ESC code!"  (ESC 'signals' that an ANSI Command follows...)

    [edit - added]  Staff - (pockets filled w/"weekend Gold") suspect that poster may have sought (further) explanation of "UARTSend()."    This code blurb aims to clarify:

    // Send a string to the UART. This function sends a string of characters to a
    // particular UART module.
    //
    //*****************************************************************************
    void
    UARTSend(uint32_t ui32UARTBase, const uint8_t *pui8Buffer, uint32_t ui32Count)
    {
    //
    // Loop while there are more characters to send.
    //
    while(ui32Count--)
    {
    //
    // Write the next character to the UART.
    //
    MAP_UARTCharPut(ui32UARTBase, *pui8Buffer++);
    }
    }

    The UART's buffer (which had been 'pre-loaded') is systematically addressed/fetched & output via the UART's TX...

  • Thanks Bob for replying to both of my post. Am trying to pick up more of c programming using peripherals 

  • Thanks cb1_mobile ! Appreciate the encouragement. Thanks for explaining the UARTsend function as well. 

  • Hello our friend,

    Staff commends you for "rising above" cut n paste style "solutions."    Thank you for your nice response.

    Real (and persisting/lasting) knowledge demands focused thought & (even) conscious effort.    You've made that commitment - (as has our small team) - and by continuing w/that curiosity & dedication a "bright future" is a proper expectation.

    Stay strong...