Transcript Lecture20

ELE22MIC Lecture 18
• The AVR Sleep Modes
• The ATMEGA128’s Timer System
–
–
–
–
Clock Sources
The 8-bit Timer 0 Modes
Clear Timer on Compare match (CTC)
Two Pulse Width Modulation (PWM) modes
• Fast Pulse Width Modulation
• Phase Correct Pulse Width Modulation
8-bit Timer/Counter 0
• The ATMEGA128 contains 4 timer
modules. The Bilby is the device we use in
lab sessions: an ATMEGA128 on a PCB.
• Each module has a selection of possible
clock or oscillator sources:
– I/O Clock, System Clock
• The Bilby’s main crystal is 7.3728MHz,
– An External low-power crystal connected to
TOSC1 & TOSC2 pins.
8-bit Timer/Counter 0
• The Bilby’s main crystal is 7.3728MHz,
• ATMEGA128 Current consumption with the main
oscillator running is in the order of 5mA.
• The Bilby’s low-power crystal connected to
TOSC1 & TOSC2 pins.
• The Bilby’s low power crystal is 32768Hz
• The ATMEGA128 has sleep modes where only this
counter remains active.
• Total current consumption with a 32768Hz crystal
clock running, in power-down sleep mode, is around
200nA (all other subsystems switched off).
Modes of Sleep - Sleep Depth
Modes of Sleep - Clock Domains
Power-Save Considerations
Every enabled CPU feature consumes extra current.
For example the Bandgap voltage reference consumes 10uA
current.
The ultra-low power-down sleep mode power consumption
can only be achieved IF the features can be switched off..
We can then achieve ultra-low power operation - suitable
for miniature battery operation.
Timer / Counter 0
• Main Features:
• Timer/Counter0 is a general purpose, single
channel, 8-bit Timer/Counter module. The
main features are:
• Single Channel Counter
• Clear Timer on Compare Match (Auto
Reload)
Timer / Counter 0
• Glitch-free, Phase Correct Pulse Width
Modulator (PWM)
• Frequency Generator
• 10-bit Clock Prescaler
• Overflow and Compare Match Interrupt
Sources (TOV0 and OCF0)
• Allows Clocking from External 32 kHz
Watch Crystal Independent of the I/O Clock
8-Bit Timer Block Diagram
8-Bit Timer Block Diagram
8-Bit Timer Counter Unit Block Diagram
8-Bit Timer Output Compare Unit
CTC Mode Timing Diagram
Fast PWM Mode, Timing Diagram
Phase Correct PWM Mode, Timing Diagram
ULN2003
Stepper Motor
ULN2003