MC68HC11 Timer System Tutorial
110 likes | 198 Views
Understand timer system functions like Input Capture, Output Compare, and Pulse Accumulator in MC68HC11 microcontroller. Implement square wave generation, delay functions, and pulse counting using polling and interrupts.
MC68HC11 Timer System Tutorial
E N D
Presentation Transcript
ECE 447: Lecture 8 Timer System
ECE447: Timer I/O Pins PA0 - 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)
Example for Input Capture 1 Unusual procedure!!! Set a flag Clear a flag #define IC1F 0x04 Cannot be done in software!!! TFLG1 = IC1F; Set by a preselected edge at the PA2 input Cleared by writing 1 to the corresponding bit location!!! ECE 447: Setting and Clearing Event Flags
ECE447: Measuring Pulse Widths 100 s < width < 32.768 ms stop start width 100 s stop start width 32.768 ms stop start Timer overflows
ECE 447: Measuring intervals <216 clock cycles FFFF stop start 0
ECE 447: Measuring intervals <216 clock cycles (overflow) 1 2 FFFF start stop 0
ECE 447: Measuring intervals >216 clock cycles 1 2 N=3 FFFF stop R start 0
ECE 447: Measuring intervals >216 clock cycles 3 N=4 1 2 FFFF R1 start R1+R2=R stop 0 R2
ECE447: Class Exercise Output Compare Write a program that generates a square wave with the frequency of 50 Hz and the duty cycle 25% at pin PA6 of MC68HC11. (use polling) Write the same function using interrupts.
ECE447: Class Exercise Delay Function Write a function in C that generates a delay specified as an argument to this function. Assume that the delay is given in the number of clock cycles. (use polling) Write the same function using interrupts.
ECE447: Class Exercise Pulse Accumulator Write a function in C that counts the number of pulses at the input PAI during the period of 30 ms. Write the same function using interrupts.