lecture8 - EEL 4744C: Microprocessor Applications Lecture 8...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
Dr. Tao Li EEL 4744C: Microprocessor Applications Lecture 8 Timer
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Dr. Tao Li Software and Hardware Engineering (new version): Chapter 14 SHE (old version): Chapter 10 HC12 Data Sheet: Chapters 12, 13, 11, 10 Reading Assignment
Background image of page 2
Dr. Tao Li We want separate timing circuitry that runs independent of our main program Our main program can't keep good timing due to unexpected things like IRQ's A timer is just a digital counter Introduction
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Dr. Tao Li Timer functionality we will studied… 1) Main Free Running Timer (TCNT) 2) Timer Output Compare 3) Timer Input Capture 4) Pulse Accumulator 5) Real Time Interrupt 6) Pulse Width Modulator Examples of application that use timer functionality 1) Count items on an assembly line 2) Generate a 30/70 duty cycle to control a motor 3) Measure phase of an incoming signal 4) Generate an edge every n seconds 5) Latch data from peripheral when an edge occurs 6) Generate interrupt every 50ms Timer Overview
Background image of page 4
Dr. Tao Li 16-bit free-running counter based on system bus clock (e.g. E CLK) 8 timer channels, each configurable as: Output compare : can generate variety of waveforms by comparing counter vs. programmable register Input capture : latch value of counter on selected edge of timer input pins 16-bit pulse accumulator to count external events, or act as gated timer of internal pulses Programmable, periodic interrupt generator called RTI (real-time interrupt) An Overview of HC12 Timer
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Dr. Tao Li Most complex subsystem of the HC12, many control registers and bits All timer functions similarly programmed All have separate interrupt controls and vectors Interrupts enabled/disabled by bit in control register All have flags that get set when some programmable condition is satisfied (reset by program) Thus, when operation of one timer is learned, procedures similar for all others Programming HC12 Timer
Background image of page 6
Dr. Tao Li The heart of the timers is a 16-bit, free running, Main Timer (TCNT) Other Timing functions are based off of this timer Its input clock from system bus clock, but may be prescaled via division by 1, 2, 4, 8, 16, or 32 PR2:PR1:PR0 prescale factors in control register TMSK2 PR[2:0] Bus Clk Divider 000 1 001 2 010 4 011 8 100 16 101 32 Basic Timer
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Dr. Tao Li TCNT ($84:85) starts at $0000 on reset, runs continuously unless disabled or stopped (e.g. wait mode) Cannot be set by program in normal mode, but contents can be read at any time TCNT should be read by 16-bit read instruction (e.g. LDD $84) to fetch whole value Overflows after $FFFF, setting Timer Overflow Flag (TOF) , which can use to extend range Basic Timer
Background image of page 8
Dr. Tao Li Timer Overflow Hardware Bus Clock
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
TOF (bit-7 in TFLG2 register) can be used in two ways: polling or interrupting Polling – program polls value of TOF; after asserted, must reset each time by writing ‘1’ to TOF bit Example: U sing TOF to generate delay of ~1s assuming 8MHz bus clock
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/13/2011 for the course EEL 4744c taught by Professor Staff during the Fall '09 term at University of Florida.

Page1 / 48

lecture8 - EEL 4744C: Microprocessor Applications Lecture 8...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online