USING OUTPUT COMPARE ON THE HC12

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



Bill Rison
2001-03-01