Go Down

Topic: Cons of using the internal 8MHz oscillator? (Read 228 times) previous topic - next topic

lukapetko2

Jan 11, 2021, 08:10 pm Last Edit: Jan 11, 2021, 08:10 pm by lukapetko2
Hello. I'm planning to use an ATmega328p. Can I use the internal 8MHz oscillator instead of the 16MHz external one? Would everything work fine, or would I encounter problems? Also, the internal one should use less power, right?
Thanks!
Thank you all for your help!

hzrnbgy

I had issue with the Atmega328P (using internal 8MHz oscillator) communicating with an ESP8266 at 115200 bps. I had to change both (ESP8266 and Atmega328P) to use 250 Kbps instead. Unless you need super accurate timing, the internal oscillator should be good enough

groundFungus

#2
Jan 11, 2021, 08:53 pm Last Edit: Jan 11, 2021, 08:56 pm by groundFungus
I have several 328 processors running at 8MHz (so I can use LiPo batteries directly) and have had no issues with serial communications or any thing else running them at that speed and supply voltage.    I bootload my chips using the MiniCore core.

nicolajna

#3
Jan 12, 2021, 12:05 pm Last Edit: Jan 12, 2021, 12:08 pm by nicolajna
The obvious con would be speed. By lowering the oscillator frequency you not only reduce the CPU execution speed, but also the clock signal to the peripherals.

In applications where speed is not really an issue, the most likely problem to face is clock error. Internal oscillators tend to be much less accurate than external ones which makes timing difficult. Peripherals which require accurate timing might also be affected, such as a UART.

The actual effect that you'll see very much depends on the device and setup. In the Electrical Characteristics of the ATmega328p datasheet, you can see that the factory calibration accuracy of the internal 8MHz@3V is +-10%. Where as the same metric according to the ATmega328pb datasheet is +-4%. You can achieve much better accuracy (+-1%) by calibrating the oscillator yourself.

But it really comes down to what your application is. A wireless thermometer? Sure. A clock? Probably not.

Datasheets:

https://ww1.microchip.com/downloads/en/DeviceDoc/ATmega48A-PA-88A-PA-168A-PA-328-P-DS-DS40002061B.pdf
https://ww1.microchip.com/downloads/en/DeviceDoc/ATmega328PB-Automotive-Data-Sheet-40001980B.pdf


lukapetko2

hzrnbgy
thanks!
groundFungus
thanks, I'll keep that in mind!
nicolajna
hmmmm, yeah. I use UART, so using an external oscillator is probably a good idea! Thanks!
Thank you all for your help!

nicolajna

hzrnbgy
thanks!
groundFungus
thanks, I'll keep that in mind!
nicolajna
hmmmm, yeah. I use UART, so using an external oscillator is probably a good idea! Thanks!
A couple of things to note. I did not say that serial communication couldn't work. Only that it's a con of using the internal oscillator and can potentially be an issue. Serial communications are typically pretty robust allowing for an error rate of roughly 5% between both the transmitter and receiver.
The factory calibration might also be bang on 8MHz every time, it's just not a guarantee. Try it out and see if it works.

lukapetko2

nicolajna
yeah, I'm definitely going to try it out. First, I'm going to see the differences in the power consumption with and without the 16MHz oscillator. Now that I have a fluke 289, I'm going to have some fun with that!
Thank you all for your help!

nicolajna

nicolajna
yeah, I'm definitely going to try it out. First, I'm going to see the differences in the power consumption with and without the 16MHz oscillator. Now that I have a fluke 289, I'm going to have some fun with that!
If power consumption is a concern and you're not in a hurry you could consider using a lower frequency crystal.

lukapetko2

Thank you all for your help!

ShermanP

I can't remember where I saw it, but there's a bootloader designed specifically for using the internal oscillator.  You flash the bootloader, then the first time it's run, it opens a connection to the serial monitor and uses the computer's traffic on TX to calibrate the AVR's OSCCAL register to 8MHz. Then it saves that value in the processor's EEPROM memory, and from then on it automatically sets OSCCAL to the right value on each power up.

But I suspect you will find very little power saving from using the internal oscillator as compared to an external crystal or resonator of the same frequency.  Of course the processor will draw less current running at 8MHz than running at 16MHz, but I don't think there's any material difference between internal and external.

CrossRoads

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up