Garbage on Serial after first character

Hi,

I'm using this code on an ATMEGA168PA@3.3V 8Mhz external cristal:

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

void loop() {

  int i = 0;
  int rx = 0;

  delay(100);
  int r = Serial.available();

  if (r > 0)
    {
      while (i < r)
        {
          rx = Serial.read();
          Serial.println((int) rx);
          i++;
        }
    }
}

The ASCII code of the first character is correct, ex:

A
<65

For two character it's mostly garbage:

AA
<65
<200

AA
<65
65

And for more it's always garbage, but the first character is always correct.

ALOA
<65
<192
<210
<187
<255

Everything was working fine on a ATTINY85 with serial software.
<

I see "3.3V" and "8MHz" and "115200". There is something going on with those numbers.

With 8MHz you get slightly different baudrates due to the calculation. I think 38400 baudrate was the magical number that was best.
I have seen a table with the differences between 8MHz and 16MHz baudrates, but I can't find it right now.
The 3.3V might result in a weaker signal.

2 questions:

How is everything connected? (USB other?)

Have you tried it with lower baud rates? starting with 9600..

Yeah, according to this: http://www.wormfood.net, almost 8% of errors explains things.

It is connected to a serial bluetooth module (RN41), I tried with 250Kb speed but the BT modules can't handle it.

38K4 is, actually, the magic number.

Many thanks.

Thanks for finding that. This is the full link : WormFood's AVR Baud Rate Calculator Ver. 2.1.1