Professional Documents
Culture Documents
theory lecture for week 4 edited by Prof Muhibul
theory lecture for week 4 edited by Prof Muhibul
theory lecture for week 4 edited by Prof Muhibul
Course Teacher: Prof. Dr. Engr. Muhibul Haque Bhuyan 19 February 2023 5
DEFAULT CLOCK SOURCE:
The device is shipped with an internal RC oscillator at 8 MHz and the fuse
CKDIV8 programmed, resulting in a 1 MHz system clock.
The start-up time is set to maximum, and the time-out period is enabled
(CKSEL = "0010", SUT = "10", CKDIV8 = "0"). The default setting ensures that
all users can make their desired clock source setting using any available
programming interface.
The term “overclocking” refers to speeding up the CPU clock for more
processing power. Intel CPUs with a “K” in the name have an unlocked
“multiplier” for easy overclocking when paired with a motherboard chipset that
supports overclocking.
Overclocking can yield improved FPS, even for high-end CPUs like the latest
Intel® Core™ i9 processor.
Course Teacher: Prof. Dr. Engr. Muhibul Haque Bhuyan 19 February 2023 6
LOW POWER CRYSTAL OSCILLATOR :
Pins XTAL1 and XTAL2 are input and output respectively of an inverting
amplifier, which can be configured for use as an on-chip oscillator.
Course Teacher: Prof. Dr. Engr. Muhibul Haque Bhuyan 19 February 2023 7
FULL SWING CRYSTAL OSCILLATOR :
This crystal oscillator is a full swing oscillator, with a rail-to-rail swing on the
XTAL2 output. This is useful for driving other clock inputs in a noisy
environment.
Course Teacher: Prof. Dr. Engr. Muhibul Haque Bhuyan 19 February 2023 8
LOW FREQUENCY CRYSTAL OSCILLATOR :
The low-frequency crystal oscillator is optimized for use with a 32.768 kHz
watch crystal. When selecting crystals, load capacitance and crystal’s
Equivalent Series Resistance (ESR) must be taken into consideration. Both
values are specified by the crystal vendor.
ATmega48P/88P/168P/328P oscillator is optimized for very low power consumption, and thus when selecting
crystals, for maximum ESR, recommended load capacitances, CL are 6.5 pF, 9.0 pF, and 12.5 pF for crystals
Note: 1. This option should only be used if frequency stability at start-up is not important for the application
Course Teacher: Prof. Dr. Engr. Muhibul Haque Bhuyan 19 February 2023 9
LOW FREQUENCY CRYSTAL OSCILLATOR :
The low-frequency crystal oscillator provides an internal load capacitance of a typical
6 pF at each TOSC pin. The external capacitance (C) needed at each TOSC pin can
be calculated by using:
C = 2*CL - CS where CL is the load capacitance for a 32.768 kHz crystal specified by the
crystal vendor and CS is the total stray capacitance for one TOSC pin.
Crystals specifying load capacitance (CL) higher than 6 pF, require external capacitors
to be applied. The low-frequency crystal oscillator must be selected by setting the
CKSEL fuses to “0110” or “0111”. Start-up times are determined by the SUT fuses.
Course Teacher: Prof. Dr. Engr. Muhibul Haque Bhuyan 19 February 2023 10
CALIBRATED INTERNAL RC OSCILLATOR:
By default, the internal RC oscillator provides an approximate 8 MHz clock. Though
voltage and temperature dependent, this clock can be very accurately calibrated by the
user. The device is shipped with the CKDIV8 Fuse programmed. This clock may be
selected as the system clock by programming the CKSEL Fuses.
When this Oscillator is selected, start-up times are determined by the SUT Fuses.
If selected, it will operate with no external components. During reset, hardware loads the
pre-programmed calibration value into the OSCCAL Register and thereby automatically
calibrates the RC oscillator.
Course Teacher: Prof. Dr. Engr. Muhibul Haque Bhuyan 19 February 2023 11
128 kHZ INTERNAL OSCILLATOR :
The 128 kHz internal oscillator is a low-power oscillator providing a clock of 128 kHz.
The frequency is nominal at 3 V and 25°C. This clock may be selected as the system
clock by programming the CKSEL Fuses to “11” .
When this clock source is selected, start-up times are determined by the SUT Fuses as shown in
the following table.
Course Teacher: Prof. Dr. Engr. Muhibul Haque Bhuyan 19 February 2023 12
EXTERNAL CLOCK:
To drive the device from an external clock source, XTAL1 should be driven as follows-
To run the device on an external clock, the CKSEL Fuses must be programmed to “0000”
Course Teacher: Prof. Dr. Engr. Muhibul Haque Bhuyan 19 February 2023 13
TIMER/COUNTER OSCILLATOR:
• ATmega48P/88P/168P/328P uses the same crystal oscillator for the Low-
frequency oscillator and Timer/Counter oscillator.
• ATmega48P/88P/168P/328P share the Timer/Counter Oscillator Pins
(TOSC1 and TOSC2) with XTAL1 and XTAL2 respectively.
• When using the Timer/Counter Oscillator, the system clock needs to be four
times the oscillator frequency. Due to this and the pin sharing, the
Timer/Counter Oscillator can only be used when the calibrated internal RC
oscillator is selected as the system clock source.
• Applying an external clock source to TOSC1 can be done if EXTCLK in the
ASSR Register is written to logic one. An external clock is selected as
input instead of a 32.768 kHz watch crystal.
Course Teacher: Prof. Dr. Engr. Muhibul Haque Bhuyan 19 February 2023 14
SYSTEM CLOCK PRESCALAR:
• The ATmega48P/88P/168P/328P has a system clock Prescaler, and the system
clock can be divided by setting the ”CLKPR – Clock Prescale Register”.
• This feature can be used to decrease the system clock frequency and the power
consumption when the requirement for processing power is low.
• This can be used with all clock source options, and it will affect the clock frequency
of the CPU and all synchronous peripherals.
Course Teacher: Prof. Dr. Engr. Muhibul Haque Bhuyan 19 February 2023 15
REGISTER DESCRIPTION:
• CLKPR-Clock Pre-scale Register
Course Teacher: Prof. Dr. Engr. Muhibul Haque Bhuyan 19 February 2023 17
REGISTER DESCRIPTION: CLOCK PRESCALER SELECT
Course Teacher: Prof. Dr. Engr. Muhibul Haque Bhuyan 19 February 2023 18
POWER MANAGEMENT AND SLEEP MODES:
Sleep modes enable the application to shut down unused modules in the
MCU, thereby saving power. The AVR provides various sleep modes allowing
the user to tailor the power consumption to the application’s requirements.
Course Teacher: Prof. Dr. Engr. Muhibul Haque Bhuyan 19 February 2023 19
POWER MANAGEMENT AND SLEEP MODES:
Course Teacher: Prof. Dr. Engr. Muhibul Haque Bhuyan 19 February 2023 20
REGISTER DESCRIPTION:
SMCR – Sleep Mode Control Register
The Sleep Mode Control Register (SMCR) contains control bits for power
management. The function of these bits (SM2:0) is shown in the next slide.
Course Teacher: Prof. Dr. Engr. Muhibul Haque Bhuyan 19 February 2023 21
REGISTER DESCRIPTION:
Course Teacher: Prof. Dr. Engr. Muhibul Haque Bhuyan 19 February 2023 22
PRR: POWER REDUCTION REGISTER:
Course Teacher: Prof. Dr. Engr. Muhibul Haque Bhuyan 19 February 2023 24