USING OUTPUT COMPARE ON THE HC12

1.
In the main program:
(a)
Turn on timer subsystem (TSCR reg)
(b)
Set prescaler (TMSK2 reg)
(c)
Set up PTx as OC (TIOS reg)
(d)
Set action on compare (TCTL 1-2 regs, OMx OLx bits)
(e)
Clear Flag (TFLG1 reg)
(f)
Enable int (TMSK1 reg)
2.
In interrupt service routine
(a)
Set time for next action to occur (write TCx reg)
  • For periodic events add time to TCx register
(b)
Clear flag (TFLG1 reg)