18
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

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

Embed Size (px)

Citation preview

Page 1: 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

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

Page 2: 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

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.

Page 3: 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

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).

Page 4: 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

Modes of Sleep - Sleep Depth

Page 5: 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

Modes of Sleep - Clock Domains

Page 6: 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

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.

Page 7: 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

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)

Page 8: 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

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

Page 9: 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

8-Bit Timer Block Diagram

Page 10: 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

8-Bit Timer Block Diagram

Page 11: 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

8-Bit Timer Counter Unit Block Diagram

Page 12: 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

8-Bit Timer Output Compare Unit

Page 13: 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

CTC Mode Timing Diagram

Page 14: 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

Fast PWM Mode, Timing Diagram

Page 15: 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

Phase Correct PWM Mode, Timing Diagram

Page 16: 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

ULN2003

Page 17: 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

Stepper Motor

Page 18: 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

ULN2003