go_away

Author Topic: Strange UART problem  (Read 1122 times)

0 Members and 1 Guest are viewing this topic.

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Strange UART problem
« on: March 15, 2009, 06:29:59 PM »
SETUP : Axon that outputs '7' (decimal of 55) through UART at 2400 baud , 8 data bits, no parity, 1 stop bit, no handshaking.
FT232 reads output of Axon's UART and displays it in my Terminal program. Terminal is set to the correct setting to "talk" with the Axon.
I used this breakout board for the FT232 - http://www.sparkfun.com/commerce/product_info.php?products_id=718
All devices have a common ground.

When all the wires are connected and THEN the devices are all turned on , then I do in fact see the correct data being received in the Terminal window.
PROBLEM: Sometimes if I disconnect the Data wire from the Axon's UART pins and then plug it back in ( while all the devices are powered on) , then I no longer receive the correct data. If I disconnect it and replug the wire while the devices are on(and therefore the Axon is still constantly transmitting UART data) , then I get either º(decimal 186)  or   Ó(decimal 211)

Here's some data that might help out
Correct Data   -  decimal of 55  , binary of 00110111
Incorrect Data - decimal of 186 , binary of 10111010
Incorrect Data - decimal of 211, binary of 11010011

My code for transmitting the UART
Code: [Select]
void SendByte(char c) {
// Syntax is SendByte(#); where # is any number
while (!(UCSR0A & (1<<UDRE0))); // Wait until you are able to send a byte
UDR0 = c; // pass the value of the c variable into the UDR ,
}

QUESTION:
How can I always receive correct data from the UART ?

Thank you
« Last Edit: March 15, 2009, 06:33:02 PM by airman00 »
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Strange UART problem
« Reply #1 on: March 15, 2009, 08:08:27 PM »
Hi,

EIA/TIA232 was never meant to be hot plugged!
So... Just don't disconnect in the middle of a transmission, You won't put a car in reverse going down the highway at full speed, would you?

That said, If you leave enough time in between transmissions, it should be able to get into synch, but you have to empty the receive buffer, or you will go on from an unknown state.

Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: Strange UART problem
« Reply #2 on: March 15, 2009, 08:15:33 PM »
Hi,

EIA/TIA232 was never meant to be hot plugged!
So... Just don't disconnect in the middle of a transmission, You won't put a car in reverse going down the highway at full speed, would you?

That said, If you leave enough time in between transmissions, it should be able to get into synch, but you have to empty the receive buffer, or you will go on from an unknown state.
Thanks Soeren that cleared it up for me!

If I use RF transmitter and RF receiver to have a wireless link I get the same problem , so I assume emptying the receive buffer like you said would solve my issue?
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,663
  • Helpful? 169
    • Society of Robots
Re: Strange UART problem
« Reply #3 on: March 15, 2009, 09:02:30 PM »
I noticed this problem when using the Blackfin with the Axon . . . I just flushed the buffer right before requesting data and the problems went away.

 


Get Your Ad Here

data_list