Uart speed problem - 115200bd

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hello, 

   

can me somebody help with uart - speed?

   

When I set up the speed of uart to 19200bd, all is ok.

   

When I set up the speed of uart to 115200, I have a problem with receiving the characters.  When I send characters from PC, uart interrupt detects twice more character.

   

For example:

   

Send from PC: HELLO

   

Receive in processor: H, null,E,null,L,null,L, null, O, null. Between characters is received the character: 0 (dec). I use the interrupt:RX FIFO not empty.

   

But in 19200bd, processor does not receive the character 0(dec).

   

The uart actual speed is 115196bd  (The CLK of processor is 48MHz). 

   

I tried to change Oversampling, CLK of processor, Stop bits, but everything does not work. 

   

Thank you for help:)

0 Likes
1 Solution
Anonymous
Not applicable

I find the problem...I call: 

   

   source = UART_GetRxInterruptSourceMasked();

   

   UART_ClearRxInterruptSource(source);

   

in the beginning of interrupt function. But it has to be in the end of this function...

View solution in original post

0 Likes
8 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Can you please post your complete project, so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

hello,

   

I am sending a project...There is CLK 47MHz a speed of uart 115196bd..

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Set UART "Byte mode" (UART advanced properties)

   

When you set the Rx and Tx Buffers to 260 and remove your interrupt handling you can use the internal routines. Check for RxBufferSize()  > 0 to see whether a character has been received.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

But it is strange...When I delete interrupt, I need to change logic of receiving datagrams...Sendig in 115200bd works good but receiving not...

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Probably you are spending too much time in your receiver interrupt handler. Use memset() instead of your for-loop, compile the module with code optimization (Do not forget to declare global vars changed in an interrupt handler as "volatile")

   

 

   

Bob

0 Likes
Anonymous
Not applicable

But I use for-loop only, when the array is full. When I send 10 char, these characters are inserted in array without for loop...(Read char -> insert to array -> increase array pointer -> end)

   

I used very slow processor - ATmega8 and it has not any problem with speed:)

0 Likes
lock attach
Attachments are accessible only for community members.
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

See attached project which runs at 1Mbaud

   

 

   

Bob

0 Likes
Anonymous
Not applicable

I find the problem...I call: 

   

   source = UART_GetRxInterruptSourceMasked();

   

   UART_ClearRxInterruptSource(source);

   

in the beginning of interrupt function. But it has to be in the end of this function...

0 Likes