I am relatively new in Atmega MCU's (too used with graphical interfaces). I am using an external clock with 8MHz in my Atmega2560. My problem is that I cannot use UART communication with PIC18->Atmega2560 and STM32F4->Atmega2560 (no acknowledgements).

I thought that it is my baud rate that is not right, maybe the Atmgea2560 is using prescaler div by 8 in default (not familiar with Atmega). So, I forcely changed the prescaler to div by 1 using this little code:

void setup() {

  CLKPR = 0x80; /*Enabling the clock prescaler function*/
  CLKPR = 0x00; /*Setting the prescaler to div by 1*/

I also use this one in the bootloading/programming:

2560.menu.clock.8MHz_external=External 8 MHz

Now, when setting the Atmega2560 Serial, Serial1, Serial2, and Serial3 to 9600 baud rate and PIC18/STM32F4 to 9600 baud rate, can my problem in UART be vanished (ack's will receive)? -theoretically

I cannot verify it now since it is weekend, things are in the office.

To those who are expert in these things, your help is much appreciated.

Regards, Tim

  • \$\begingroup\$ With an 8MHz clock 57600 bps is not possible with good enough accuracy. 9600 is possible with better than 1% accuracy. \$\endgroup\$ Mar 5, 2021 at 19:08

1 Answer 1


Datasheet recommends baud rate error below 2% under standard 16x oversampling mode. So with a 8 MHz clock, 57600 is not achievable, error is more than 3.5%, which is too close to the max total error of 4.5%.

Now, using U2X mode for only 8x oversampling, 8MHz clock can achieve 57600 with error of only 2.1%. Unfortunately it still exceeds the recommended error of 1.5% of U2X, even thouh it is less than max total error of 3.9%.

So, 57600 is not achievable with 8 MHz clock, it is not recommended by manufacturer.

However 38400 and many other baud rates are achievable with much below 1% error.

If you are able to change the clock to something more suitable like 7.372800 MHz, it is possible to achieve bit rate of 230400 with 0% error.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.