I) Timer Output Compare - Motorola 68HC12 User Manual

Table of Contents

Advertisement

Timer Output Compare
The output compare on the 68HC12 is very similar to that of the 68HC11.
selects an action to occur when the output compare is triggered and the time at
which the action occurs. The processor will then carry out this action accordingly.
The first step is to select which channel(s) will be used.
the _H12TIOS register as explained above.
select when the output compare will trigger.
the _H12TCx register(s) that correspond to the channel(s) that was selected as an
output compare in _H12TIOS.
It is then necessary to determine what action will occur when the output compare is
triggered.
There are several different actions that are possible, which one occurs
is determined by the values in _H12TCTL1 and _H12TCTL2. These registers contain the
control bits for each channel, OMn and OLn.
have are listed in Table 4.
Table 4: Output compare actions
OMn
OLn
0
0
0
1
1
0
1
1
_H12TCTL1:
bit 7
bit 6
OM7
OL7
_H12TCTL2:
bit 7
bit 6
OM3
OL3
Having determined the action taken on a successful match, the next step is to make
sure timer interrupts are disabled.
Lastly the timer module is enabled, as shown above, allowing the output compare to
trigger.
It is important to note when using the output compare that when an output compare
action is triggered the corresponding bit of Port T will automatically be set as an
output, regardless of the state of DDRTT.
Sample Code
This code sets up an output compare and causes the pin output to toggle when the
interrupt is triggered.
_H12TIOS=0xFF;
_H12TMSK1=0x00;
_H12TCTL1=0x5A;
_H12TCTL2=0x5F;
_H12TC0=0x0000;
_H12TC1=0x2000;
_H12TC2=0x4000;
_H12TC3=0x6000;
_H12TC4=0x8000;
_H12TC5=0xA000;
_H12TC6=0xC000;
_H12TC7=0x9000;
_H12TSCR=0x80;
Action______________________________
Timer disconnected from output logic
toggle Ocn output line
clear Ocn output line to 0
set Ocn output line to 1
bit 5
bit 4
OM6
OL6
bit 5
bit 4
OM2
OL2
// set up the channels as output compare
// no hardware interrupts
// set OC7, OC6 for toggle/ OC5,OC4 clear
// set OC3, OC2 for toggle/ OC1,OC0 set
// set different trigger times
// turn on the timer
Having done this, the next step is to
This is done by writing a value to
The effect that the different values
bit 3
bit 2
OM5
OL5
bit 3
bit 2
OM1
OL1
This is done by writing 0x00 to _H12TMSK1.
13
This is done by using
bit 1
bit 0
OM4
OL4
bit 1
bit 0
OM0
OL0
The user

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents