Electronics > Microcontrollers

Why is an external oscillator needed?

(1/3) > >>


I have come across several circuit diagrams where an external oscillator is connected to a microcontroller that already has an oscillator built-in. Why would someone want to do this, and how does the microcontroller know which oscillator takes priority?

Here's an example:

The AtMega1284P has an internal 20MHz oscillator.

The internal oscillator isn't very accurate and it can cause problems when you use the UARTS to communicate or do anything which requires exact timing

If you checkout the UART section of the datasheet you will notice tables of UART error rates at various clock frequencies.
For the UART to work without communication errors it requires a clock rate that's a multiple of the serial baudrate which is where an external oscillator is useful.
You will also notice that the built in oscillator cannot go as fast as the micro supports. On AVRs they often max out at 8mhz while the chip may run up to 20mhz

There's no "priority", you need to tell the microcontroller which clock source to use using the fuse bits (and what speed to run at if using the builtin oscillator).

Thank you for the speedy reply. So if you're not using serial communication, the internal oscillator may serve just fine?

Yeah, if you're not doing anything that needs a fast clock or exact timing the internal oscillator will work fine.

Serial communication will actually work using the internal oscillator if you pick your baudrate wisely.
Its just more prone to getting a character wrong every so often.

Thanks again.

If the oscillator frequency is say 5x the desired baud rate, how exactly do you go about converting that multiple from 5x to 1x? Do you use a prescaler?

If a prescaler is used, then couldn't you apply the prescaler to just about any frequency you want, and not have to worry about getting a multiple of the baud?


[0] Message Index

[#] Next page

There was an error while thanking
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod