Electronic – Using the ATMega328 with the internal oscillator

atmegaavrclockoscillator

I have a project that I think would be best suited for an ATMega328P. However, in every simple project I've seen, people always hook up a 16MHz external oscillator. From what I can see, it should have an 8MHz internal oscillator. My project doesn't require a lot of processing power, nor does timing need to be very precise(other than for a UART and I2C). I have a programmer also, so I don't need to worry about bootloaders.

Is there any reason for me to use an external oscillator?

Best Answer

What you don't say is what the accuracy of this internal oscillator is. It took me some time to find it in the datasheet, on page 369.

10%. Ten percent! And that for a calibrated oscillator? This is awful. It isn't unreasonable to expect error as low as 1% for this. Microchip/Atmel provides a document for calibrating the oscillator yourself to 1% accuracy.

I2C is a synchronous protocol, and timing accuracy isn't relevant as long as minimum and maximum pulse times are respected.
UART on the other hand is asynchronous, and then timing accuracy is important indeed. Most UARTs allow a half bit error in the last bit (the stop bit), so that's 5% for a 10 bit transmission.

The factory calibrated oscillator won't do here. You'll have to go through the calibration procedure to get to 1%. In that case you can use the internal oscillator. Otherwize you'll have to use a crystal.