| by Arround The Web | No comments

Does Arduino Have Internal Hardware Clock

Arduino is a microcontroller-based platform designed for executing different instructions according to project requirements. To synchronize all this operation a clock is used with microcontrollers. Clock is like the heartbeat of Arduino boards required to generate clock pulses. These clock pulses synchronize all the internal and hardware operations. Microcontrollers are reliant upon clock. The clock determines how efficient and fast a microcontroller is to execute instructions. Now we will highlight clock sources used inside Arduino boards.

Does Arduino Has Internal Hardware Clock

Yes, Arduino has an internal hardware clock. Arduino Uno boards have two microcontroller chips onboard one is ATmega328p and second one is ATmega16u2. Both these microcontroller chips have an internal clock of 8Mhz. ATmega16u2 is used for serial communication between Arduino board and computer while ATmega328p is the main controller on Arduino board used for logic building.

Internal Hardware Clock Source

Arduino has two sources for internal hardware clocks as described above. Both are used to drive two separate microcontrollers.

1. ATmega328p Clock

The Arduino Uno ATmega328p controller normally uses an external crystal oscillator for its clock which is 16MHz, but it also has an internal clock generator of 8Mhz. We can configure the microcontroller internal oscillator as a source of 8Mhz clock signal.

ATmega328p comes with an RC oscillator having an 8MHz clock signal. Its fuse CKDIV8 is programmed according to 8MHz frequency, which results in a 1.0MHz system clock. This default clock source gives freedom to users that can design their desired clock with any programming interface. Maximum value is set for startup time of ATmega328p microcontroller.

By default, following clock configurations comes in ATmega328p microcontroller and an external clock source can also be attached:

  • Calibrated Internal RC Oscillator
  • 128kHz Internal Oscillator
  • External Clock Source

Calibrated Internal RC Oscillator

Internal RC oscillator provides a microcontroller 8.0MHz clock. This clock source is dependent upon temperature and voltage levels which means slight change in these conditions can affect microcontroller performance. To select this clock for microcontroller generally CKSEL fuses are programmed. If we select his settings clock will operate without any external source following frequency range can be achieved by programming CKSEL fuses as:

Frequency Range (MHz) CKSEL3…0
7.3-8.1 0010

128kHz Internal Oscillator

128kHz is also a default clock for ATmega328 microcontroller. It is a low power oscillator and not designed for high accuracy requirements Its frequency is optimum for 3V and 25 degree C temperature. To select this clock, we have to set the value of CKSEL fuses to ‘’0011”. Following frequency range can be obtained by CKSEL fuses:

Frequency Range (kHz) CKSEL3…0
128kHz 0011

External Clock Source

ATmega328p is designed in such a way that to increase its instruction execution speed we can attach an external clock source of 16MHz-20MHz such as ceramic resonator as used in Arduino Uno.

To drive the microcontroller using external clock sources we have two pins available for an oscillator XTAL1 and XTAL2. Arduino Uno uses these two pins of ATmega328p to connect an external ceramic resonator for its frequency requirement as this clock source is more efficient than internal 8MHz clock.

Pins 9 and 10 are used to connect the two pins of the external oscillator. Following table shows pin configuration for external clock source:

Pin 9 XTAL External Oscillator Connect Pin 9 of microcontroller to one Pin of the external oscillator
Pin 10 XTAL External

Oscillator

Connect Pin 10 of microcontroller to second Pin of the external oscillator

2. ATmega16u2 Clock

Arduino Uno uses ATmega16u2 as a microcontroller for serial communication between Arduino and computer. This microcontroller acts as a USB to TTL converter. Like ATmega328p this microcontroller also comes with an 8MHz internal RC oscillator and a system clock of 1MHz. Startup time is set to maximum value. All these settings help users to program it with any programming interface and design their required clock source or attach an external oscillator to increase microcontroller efficiency.

By default, following clock configurations comes in ATmega16u2 microcontroller and an external clock source can also be attached:

  • Calibrated Internal RC Oscillator
  • PLL
  • External Clock Source

Calibrated Internal RC Oscillator

ATmega16u2 has a built-in RC oscillator which can give Arduino up to 8MHz of clock. It is also temperature dependent so variation in heat and voltage can affect microcontroller performance. This clock can be selected by programming internal CKSEL fuses. During Reset OSCCAL register reaches its default value and it doesn’t require any external clock source when selected at default 8MHz value of oscillator. Following are the operating modes for calibrated internal oscillator:

Frequency Range (MHz) CKSEL3…0
7.3-8.1 0010

PLL

PLL is used to generate a high range of frequency specially for USB serial communication between Arduino and computer. It can generate up to 48MHz of frequency. PLL receives input low frequency from its XTAL pin, or any other external clock source like in Arduino Uno Crystal oscillator is used as a clock source for serial communication that helps ATmega16u2 for USB to TTL conversion.

External Clock Source

In the same way like in ATmega328p microcontroller we can also configure an external clock with ATmega16u2. When using an external clock source sudden changes in clock frequency should be avoided for smooth operation of MCU. In Arduino Uno crystal oscillator is used as a source of external clock for microcontroller. Crystal oscillator is more efficient than its competitor ceramic resonator because of low cost and high voltage and frequency tolerance. CKSEL fuses must be programmed to run an external oscillator.

External clock source can be connected in below configuration:

Diagram Description automatically generated

Pin 1 XTAL1 External Oscillator Input to oscillator amplifier and internal clock
Pin 2 XTAL2/PC0 External Oscillator Output from oscillator when enabled by fuse, can be used as I/O pin also

Conclusion

Arduino boards are very much flexible in terms of clock sources. Arduino has two microcontrollers on board which are ATmega328 and ATmega16u2. Both these microcontrollers come with an internal 8MHz clock but to get maximum output and increased performance we use an external clock of 16MHz for both separately. Here we discussed how Arduino microcontrollers can be used with their internal clock oscillator and highlighted the possible way of adding an external clock.

Share Button

Source: linuxhint.com

Leave a Reply