Monday, 30 January 2017

oscillator - When do we need an external crystal for an Atmega chip?



I have created a microcontroller circuit, based on the most used circuits I could find on the Internet -- which use an external crystal. As I know, Atmega16 has an internal oscillator which operates at 1 MHz by default. So, the microcontroller can be used without an external crystal. But now I am confused -- do I need an external crystal for my microcontroller circuit? I am just using ADC, USART, and LM35. I don't know if the internal oscillator is enough, good, or etc to be used.


So, when do we need an external crystal for our microcontroller?



Answer



Two main reasons I can think of are...




  1. You want to run at a higher clock speed than available with the internal oscillator. For the Atmega16 chip you mentioned, the internal oscillator has maximum speed of 8MHz, but you can run the chip at up to 16MHz with an external crystal.




  2. You need precise and accurate timing. With some effort you can calibrate the internal RC clock to within +/1% accuracy, but a cheap ($1) 16MHz crystal can be accurate to 0.005% (50ppm) out of the box. The internal RC oscillator is also more sensitive to temperature and voltage changes, so an external crystal will generally be more stable.





Why would you care about increasing maximum clock speed? Running twice as fast means you can get twice work as much done in the same time- or the same amount work in half the time. Or you can generate/count signals at double the frequency.


Why would you care about having a precise and accurate clock? Maybe you want to locally keep track of the number of seconds you have been running. After 1 week, you can be off by more than an hour with a %1 oscillator whereas you should be within half a minute with a 50ppm crystal. Or you might care about time on a very short scale- for example generating serial data bits where being off by 1% on either side of a link could be enough cause framing errors.


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...