{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture8-6pg - Reading Assignment EEL 4744C Microprocessor...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Dr. Tao Li EEL 4744C: Microprocessor Applications Lecture 8 Timer 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 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 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 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 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
Image of page 1

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

View Full Document Right Arrow Icon
2 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 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 Dr. Tao Li Timer Overflow Hardware Bus Clock Dr. Tao Li 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 122 overflows, each of 64K periods of 125ns (8.192ms) 122 × 64K × 125ns 1 second!
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}