11
ECE 447: Lecture 8 Timer System (1)

ECE 447: Lecture 8 Timer System (1). ECE 447: 68HC11 Timer System 1.Generating delays - imposing a specific delay between two points in the program by

Embed Size (px)

Citation preview

Page 1: ECE 447: Lecture 8 Timer System (1). ECE 447: 68HC11 Timer System 1.Generating delays - imposing a specific delay between two points in the program by

ECE 447: Lecture 8

Timer System (1)

Page 2: ECE 447: Lecture 8 Timer System (1). ECE 447: 68HC11 Timer System 1.Generating delays - imposing a specific delay between two points in the program by

ECE 447: 68HC11 Timer System

1. Generating delays - imposing a specific delay between two points in the program by polling.

label 1

label2

instr1instr2

instrN

delay

2. Pulse accumulation - counting the number of pulses

Page 3: ECE 447: Lecture 8 Timer System (1). ECE 447: 68HC11 Timer System 1.Generating delays - imposing a specific delay between two points in the program by

ECE 447: 68HC11 Timer System

3. Input capture - measuring the time between signal edges

4. Output compare - generating signals with the given timing characteristics

start stop

start stop

pulse width

single pulse periodical signal

period

Page 4: ECE 447: Lecture 8 Timer System (1). ECE 447: 68HC11 Timer System 1.Generating delays - imposing a specific delay between two points in the program by

ECE 447: 68HC11 Timer System

5. Real Time Interrupt – Produce a period signal for the 68HC11.

period

The Real Time Interrupt will allow a piece of code to be executed at a given period. This can be used to implement a Real-Time clock.

Page 5: ECE 447: Lecture 8 Timer System (1). ECE 447: 68HC11 Timer System 1.Generating delays - imposing a specific delay between two points in the program by

ECE447: Timer I/O PinsPA0 - Input Capture 3 (IC3)

PA1 - Input Capture 2 (IC2)

PA2 - Input Capture 1 (IC1)

PA3 - Input Capture 4/ Output compare 5 (IC4/OC5)

PA4 - Output Compare 4 (OC4)

PA5 - Output Compare 3 (OC3)

PA6 - Output Compare 2 (OC2)

PA7 - Pulse Accumulator Input (PAI)

Page 6: ECE 447: Lecture 8 Timer System (1). ECE 447: 68HC11 Timer System 1.Generating delays - imposing a specific delay between two points in the program by

ECE 447: Setting and Clearing Event Flags

Example for Input Capture 1

Unusual procedure!!!

Set a flag Clear a flag

#define IC1F 0x04

TFLG1 = IC1F;

Cannot be done in software!!!

Set by a preselected edgeat the PA2 input

Cleared by writing 1 to thecorresponding bit location!!!

Page 7: ECE 447: Lecture 8 Timer System (1). ECE 447: 68HC11 Timer System 1.Generating delays - imposing a specific delay between two points in the program by

ECE447: Measuring Pulse Widths

Timer overflows

100 s < width < 32.768 ms

width 100 s

width 32.768 ms

start stop

start stop

start stop

Page 8: ECE 447: Lecture 8 Timer System (1). ECE 447: 68HC11 Timer System 1.Generating delays - imposing a specific delay between two points in the program by

ECE 447: Measuring intervals <216 clock cycles

start

0

FFFF

stop

Page 9: ECE 447: Lecture 8 Timer System (1). ECE 447: 68HC11 Timer System 1.Generating delays - imposing a specific delay between two points in the program by

ECE 447: Measuring intervals <216

clock cycles (overflow)

start

0

FFFF

1 2

stop

Page 10: ECE 447: Lecture 8 Timer System (1). ECE 447: 68HC11 Timer System 1.Generating delays - imposing a specific delay between two points in the program by

ECE 447: Measuring intervals >216 clock cycles

start

stop

0

FFFF

1 2 N=3

R

Page 11: ECE 447: Lecture 8 Timer System (1). ECE 447: 68HC11 Timer System 1.Generating delays - imposing a specific delay between two points in the program by

ECE 447: Measuring intervals >216 clock cycles

start

stop0

FFFF

1 2 3

R2

R1

N=4

R1+R2=R