I need an clearity about external crystal oscilator. I got communication between esp32 and atmega8/88/328 processor, I use atmega wih internal oscillator and looks like it have problem with serial communication (some time it lose data, or replace it with nonsences).

So i have read that should use extercal crystal oscillator to achieve stable uart communication.

Question is that, what frequency to choose, and how that gonna effect uart, and atmega processor lifetime. I know if choose 16mhz processor gonna run faster, but assume it life time will decrease compated with 1mhz or 8mhz. What about uart, which one of those frequences are best for it, or it make no difference?

  • the lifetime of your atmega won't be affected. you just need to make sure if the atmega is meant to run at that frequency. Regarding your uart? you need to make sure that you adjust the prescaler so the baudrate remains correct. – Tarick Welling Jun 17 '19 at 9:50

There are some specific crystal oscillator frequencies named 'UART friendly'. Using these frequencies would lower % error in UART communications. Please refer to the table in the datasheet, in chapter named "BAUD rate settings" (datasheet of ATMega328: '24.11. Examples of Baud Rate Setting'). There are tables to show error percentage. What to look at is "Error" column. fosc is selected oscillator/crystal frequency. For succesful UART communication you aim for less than 3.5% Error.
Your crystal speed should depend on your desired communication speed, for example for me the preferred ones are 11059200Hz or 1843200Hz.

enter image description here enter image description here
or below:
enter image description here

With raising frequency you may expect power consumption and the chip's temperature rise, anyway I wouldn't worry too much about life shortening. More important here would be power consumption rise. Do you want the chip(device) to be battery powered? To save on energy you can also consider lower frequencies like 1.8432MHz or 3.6864MHz.

| improve this answer | |
  • 1.84mhz is uart friendly for almost all rates, but In arduino ide there is no such frequency to select – user3503519 Jun 17 '19 at 11:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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