How does an external clock in a microcontroller work?

How does an external clock in a microcontroller work?

An external clock source allows the use of a very accurate and stable device such as a TCXO (temperature-compensated crystal oscillator). A clock source is selected with a multiplexer and input to a prescaler which divides the clock by a factor of 32,768 (215) to produce a one-second clock.

Can a microcontroller tolerate a bad oscillator?

In my experience, many applications can tolerate the shortcomings of an internal oscillator, especially when the frequency has been calibrated at the factory. With older microcontrollers, the internal oscillator might have tolerance as bad as ±20%.

Can a microcontroller change the time of day?

Changing the time requires a complete reset of the microcontroller. Some RTCs have hardware counters to maintain the time of day and calendar date. This requires counters for minutes, hours, days, months, years, and consideration for leap years. Time of day and calendar dates can also be kept by software.

How are RTCs used in a microcontroller?

There are RTC devices external to a microcontroller which interface with an I 2 C or SPI bus. This article describes RTCs inside a microcontroller. The real-time clock’s basic function is to produce intervals of one second and maintain a continuous count.

Why do you need stability in a microcontroller?

Frequency stability is the main one, particularly for serial comms at high speed. But that also brings up the occasional need for a crystal at a seeming odd frequency to get an exact baud rate, because of the limited options that the clock dividers give you. I have actually come across a scenario where 1% was not good enough for UART.

What kind of clock does an RTC use?

An RTC often has its own internal oscillator with an external crystal and an option to use an external frequency reference. All clock sources run at 32,768 Hz. An external clock source allows the use of a very accurate and stable device such as a TCXO (temperature-compensated crystal oscillator).

What’s the maximum frequency of an external clock?

The external clock (EC) mode uses external oscillator as a clock source. The maximum frequency of this clock is limited to 20 MHz. The advantages of the external oscillator when configured to operate in EC mode: It is possible to synchronize the operation of the microcontroller with the rest of on-board electronics;