Page 2 of 2

Re: UART1_Read_text problem

Posted: 25 Jul 2013 17:19
by granel
hello, Marina
using ATmega16 - 14,745600 MHz
Sending to ATmega hex code, for example -- 20 21 22 23 24 25 26 27 28 29 30 0D 0A

Using C code -- UART_Read_Text(uart_rd_txt, "0", 13);
UART_Write_Text(uart_rd_txt);
Receive -- with errors --> 20 21 22 23 24 25 26 27 28 29
0D 0A 20 21 22 23 24 25 26 27 28 29
0D 0A 20 21 22 23 24 25 26 27 28 29
0D 0A 20 21 22 23 24 25 26 27 28 29
0D 0A 20 21 22 23 24 25 26 27 28 29
..................


Using C code -- UART_Read_Text(uart_rd_txt, 0x30, 13);
UART1_Write_Text(uart_rd_txt);
Receive -- bad code --> 49 6E 96 74 0D 0A
49 6E 96 74 0D 0A
49 6E 96 74 0D 0A
49 6E 96 74 0D 0A
............

Using C code -- UART_Read_Text(uart_rd_txt, 48, 13);
UART_Write_Text(uart_rd_txt);
Receive --bad code --> 49 6E 96 74 0D 0A
49 6E 96 74 0D 0A
49 6E 96 74 0D 0A
........
/*at code start have:
UART_Write_Text("Init");
UART_Write(13); //0x0D
UART_Write(10); //0x0A
*/

//48 -- 0x30 -- "0"
this code like black box :(((((
UART_Read_Text(x, y, z);
I tried it all day :(((((

Re: UART1_Read_text problem

Posted: 26 Jul 2013 13:21
by marina.petrovic
Hi,

When you take a look at help file (UART Library) - UART_Read_Text() function you will see that delimiter need to be
sequence of characters that identifies the end of a received string.

In the firs example when you use delimiter = "0", you have errors in code because you send "0" in some moment,
but USART Terminal "see" that character as delimiter.

I tried to send: 21 22 23 24 25 26 27 28 29 30 0D 0A

And use letter M as delimiter:
UART1_Read_Text(uart_rd_txt, "M", 40);
UART1_Write_Text(uart_rd_txt);

Result is correct: 21 22 23 24 25 26 27 28 29 30 0D 0A

Best regards,
Marina

Re: UART1_Read_text problem

Posted: 26 Jul 2013 14:01
by granel
Thank you , will try.

Re: UART1_Read_text problem

Posted: 26 Jul 2013 14:05
by granel
can I use like delimiter --> "M" or 0x4D or 77 (dec.) ?

Re: UART1_Read_text problem

Posted: 26 Jul 2013 15:39
by marina.petrovic
Hi,

I said "M" for no particular reason, just thought that you can try to use some letter or a word ("OK") that you don't send.

Delimiter must be sequence of characters (with zero terminating character) and you can use any sequence that you want.

Best regards,
Marina