Title: Output Captur
1Output Capture
2Output Capture Function
- inform the 68HC11 to conduct a specific action
when a specific time is arrived - similar to an alarm clock - When the real-time of
the clock is equal to the preset alarm time, the
alarm is activated - Five output compare channels are provided OC1,
OC2, OC3, OC4 and OC5. - Each function is implemented with three
functional hardware blocks an output-compare
register, a dedicated 16-bit comparator and
interrupt generation logic
3(No Transcript)
4Output Compare Registers
5Timer Control Register TCTL1
6Timer Interrupt Mask Register 1 (TMSK1)
Timer Interrupt Flag Register 1 (TFLG1)
7Example
- include lthc11.hgt
- main ( )
-
- PORTA 0x40 / set OC2 pint to high /
- TCTL1 0x40 / select toggle as the OC2 pin
action / - TOC2 TCNT 800/ start an OC2 operation with
800 E cycles / - TFLG1 0x40 / clear OC2F flag /
- while (1)
- while (!(TFLG1 0x40)) / wait for 400 ms /
- TFLG1 0x40
- TOC2 1200 / start next OC2 operation with
1200 E cycles / while (!(TFLG1 0x40)) - TFLG1 0x40
- TOC2 800
-
- return 0
8OC1 - Control up to 5 Multiple Output-Compare
Functions
OC1M (100C)
OC1D (100D)
9What does this program do?
main () unsigned int oc1_cnt PACTL
0x80 / configure PA7 for output / OC1M
0xF8 / allow OC1 to control OC1-OC5 pins
/ TFLG1 0x80 / clear OC1F flag / TOC1
TCNT 20000 / start an OC1 operation with 10
ms delay / while (1) OC1D 0xA8 /
prepare to set PA7, PA5, and PA3 to high
/ oc1_cnt 500 / number of OC1 operations
to create 5 s delay / while (oc1_cnt)
while (!(TFLG1 0x80)) TFLG1 0x80 /
clear OC1F flag / TOC1 20000 / start the
next OC1 operation / oc1_cnt -- OC1D
0x50 / value to pull PA6 and PA4 to high
/ oc1_cnt 500 while (oc1_cnt) while
(!(TFLG1 0x80)) TFLG1 0x80 / clear OC1F
flag / TOC1 20000 / start the next OC1
operation / oc1_cnt --