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.

TM4C12x UART termination character

Other Parts Discussed in Thread: TM4C1294NCPDT

Hello everyone, 

I have one question regarding UART receiving data. For this project, I have a Win App which connects to the serial port and transmits and receives data from one side, and on the other the side I have Tiva Launch Board with TM4C1294NCPDT. I adjusted example from UART peripheral to get Tiva receive chars on interrupt and perform reading and echoing received data with following two lines

incoming[i]=UARTCharGet(UART0_BASE);
UARTCharPut(UART0_BASE, incoming[i]);

Now I want to build in some kind of detection of last bit in received "frame". I noticed that last time interrupt triggers hex value 0x0A is read (dec 10, bin 00001010...). I do not send that character from my win app so I assume this is some kind of terminating character but I can't find anything in the datasheet. Am I right? Can this be used to detect string termination? Should I write some kind of the different end of transmission detection? 

Also, my board will have to listen UART all the time so I did not use FIFO but set UART to receive byte after byte, is that right way to do?

  • This thread has been moved to the TM4C forum.

    Regards,
    Ryan
  • Usually - but not always - the "normal" serial termination protocol includes 0x0A and 0x0D. (or some combination of those - 0D=CR (carriage return) 0A=NL (new line/line feed))
     
    The Win APP usually will list these - and provide a means for you to alter and/or disable...

  • Hello Djedjica,

    The UART frame has a stop condition in the frame itself. The UART controller detects that Stop bit and then writes the data to the Buffer. I don't think a special condition is required.

    Having a FIFO is always beneficial, as the application grows and it is required that CPU perform more tasks.

    Regards
    Amit
  • Ryan Brown1 said:
    This thread has been moved to the TM4C forum.

    ...just typed in my answer in the MSP forum...then when pressing on "Post" the thread was not available anymore...so I'm now here!

    Hi!

    0x0A is the LF character (line feed). This is a common character to signal the end of a transmission, sometimes in combination with CR (carriage return) which is 0x0D. If your TM4C controller has this character in it's RX buffer, then the App definitely sent it. It is not the processor that will add 0x0A - how should it know it is the end of the transmission. So look into the program on your PC to find out where this character is added. In terminal programs, for example, you can set the transmission end character that is then added to each transmission automatically.

    Not using a buffer is OK if your application is fast enough to handle the incoming bytes on the fly - this is no problem in most cases, at least when not using super fast baudrates. But as Amit said, when your processor is super busy with important stuff, you may want think about it. The processor then can process tasks when it has finished other things.

    Djedjica said:
    Also, my board will have to listen UART all the time so I did not use FIFO

    Even if you had one you still have to react on the UART's incoming bytes. You could of course use a DMA controller, but then it would be helpful to have transmissions with a fixed length to know when a complete set of data was received.

    Dennis

  • And it is said that "vultures" descend quickly on the plain Serengeti...

  • First, thank you all for very quick response, and you are right I was sending that, stupid of me not to figure that before, in win app i was using serialPort.WriteLine(), I suppose it adds this character for a new line. Sorry for asking the stupid question, nevertheless I got useful information of it.

    MCU only receives frame, and according to data received it will start a relay or something not sure jet, but nothing that needs quick response and not much of data will be sent but I need it to listen and to be able to receive UART data at any moment.

    Mr. Ashara you mentioned stop condition, how can I check if this condition is met? This is my interrupt routine, I was thinking to check if

    This is my interrupt routine, I was thinking to check if the character is some character that I insert myself on the end of the string (ch_EOT) and if it is I raise flag and process incoming data. Can you advise me to do something more suitable? I also do not like on inserting myself some character, since this will be embedding in the application form the third party?

    void UART0_ISR(void)
    {
    	uint32_t ui32Status;
    	ui32Status = UARTIntStatus(UART0_BASE, true);
    	UARTIntClear(UART0_BASE, ui32Status);
    	if(ui32Status&UART_INT_TX)
    	{
    		TXcount++;
    	}
    
    	while(UARTCharsAvail(UART0_BASE)) //loop while there are chars
    	{
    		incoming[i]=UARTCharGet(UART0_BASE);
    		UARTCharPut(UART0_BASE, incoming[i]); //echo character
    		if(input[i]==ch_EOT)
    		{
    			flag_EOT_RS485=1;
    			//i=0;
    		}
    		else
    		{
    			flag_EOT_RS485=0;
    			i++;
    		}
    
    	}
    }

  • Hello Djedjica,

    There is no STOP interrupt condition. Only data received interrupt.

    Regards
    Amit
  • Yes, I understand, sorry for being bit confused it's been a long day. Thing is that, for example if I send

    'abcd'

    I count 5 interrupts triggered (4 letters + '\n'). So I'm using this condition in the end to know when full string is received, I referred to it as a frame. So when You mentioned :

    "The UART frame has a stop condition in the frame itself. "

    I thought it would be at the end of a string, but actually, it is at the end of the byte. FIFO is disabled in UART config function.

  • Hi,

    You should specify what kind of "data" you transfer over UART - either pure text, and in this case the LF character should be precessed as its name said or the data is binary - e.g the number 0x3F0A is sent LSB first, so first is 0x0A and should not be removed or any other action taken on it.

    Take care with your PC application, there are some other hidden problem(s) with drivers/software from MS (i.e, 0x0 has also a special treatment).

  • Hello Djedjica,

    OK, I was thinking on a different line. There is no method for UART in hardware to detect the end of frame. You would need to check the ASCII code to see if the end of frame character is received.

    Regards
    Amit