Strange Characters or ASCII-Numbers when sending more then one Character

Hello!

I recently ran into a really strange problem.
I was trying to send multiple digit integers to set a clock for a project I’m working on.
But I noticed that numbers were not send/received correctly.
The simplify the issue, I created a test program:

Arduino Code:

byte aIn;

void setup() {
  Serial.begin(115200);
}

void loop() {
  if(Serial.available()){
    aIn = Serial.read();
    Serial.write(aIn);
    Serial.write(' ');
    Serial.println(aIn);
  }
}

Console Output: (First sending individual characters (1,2,3) and then all three a once (123), no line ending)

1 49    //Send: 1
2 50    //Send: 2
3 51    //Send: 3
1 49    //Send: 123
¦ 166
þ 254

It is working fine on my Arduino Leonardo R3, but not on my ATMEGA32 (using MightyCore for Compatibility).
My Board Settings are attached, I upload using my USBtinyISP and an FTDI for the Serial Interface.

MightyCore: GitHub - MCUdude/MightyCore: Arduino hardware package for ATmega1284, ATmega644, ATmega324, ATmega324PB, ATmega164, ATmega32, ATmega16 and ATmega8535
USBtinyISP: http://www.ebay.at/itm/281608357433
FTDI: http://bit.ly/23zqxHB

I’m not new to programming and I’ve done a lot with Arduino/AVR.
This problem applies to all characters I send, not just numbers.

I hope someone can help me.

Have a nice day!

ATMEGA32.PNG

Hi big12boy!

I am currently working on my Diploma thesis and encountered a simillar problem with my project.

Did you try turning it OFF and ON again??? :smiley:

I hope that I could help you with your problem :smiley:

Have a nice day!

I get the expected values.

1 49
2 50
3 51
1 49
2 50
3 51

Thanks for the answer Whandall!
What Processor are you using?

And the code is working with my Leonardo, but not on my ATMEGA32 @ 8MHz 3.3V.

BTW: PapayaWrip is my colleague in the project I'm working on ... just ignore him ^^

I ran it on a Mega2560 16MHz.

Fixed it!

It doesn't work with a Baudrate of 115200, all other ones work....

I should have checked that first... doohhh

Thanks anyways!

Have a look at this site WormFood's AVR Baud Rate Calculator Ver. 2.1.0, it shows what works and what probably wont.