Difference between UART Teensy and USB to UART

Status
Not open for further replies.

2n3055

Well-known member
Hello,

I'm using a Teensy 3.2.

I receive 9600bd datas. I'll read it with the Teensy but it's not correct, as if the baud rate is not correct.

The board send 1 and 0:

Teensy display:
31
D
A
30
D
A

Strange value

With my MAC with an USBtoUART:
1
0

That is correct!!



With the scope the shortest pulse is 104us (it seems correct for the 9600bd).

Code:
void loop() 
{
  byte Command;

  if (Serial1.available() > 0)
  {
    Command = Serial1.read();
    DebugSerial.print("Decoded: ");
    DebugSerial.println(Command, HEX);
  }
}

What do I wrong????

Thanks
 
Your serial data is working correctly. You are printing out what it receives in HEX.
31 is hex for the ascii number 1.
30 is hex for the ascii number 0.
D is hex for a carriage return.
A is hex for a line feed.
 
Did you want to print the hex value, or write it?
https://www.arduino.cc/en/Serial/Write
If you look at an ascii table such as
http://www.asciitable.com/
you will see that character one is ascii code 31, ascci code 0 is 30
D and A are Ascii codes for line feeds.

So your Teensy is correctly getting a char representing one of two numbers plus two end of line codes but is writing them out as numbers.

Edit: took to long looking up the codes and got beaten to it.
 
Status
Not open for further replies.
Back
Top