USING OUTPUT COMPARE ON THE HC12
- In the main program:
- Turn on timer subsystem (TSCR reg)
- Set prescaler (TMSK2 reg)
- Set up PTx as OC (TIOS reg)
- Set action on compare (TCTL 1-2 regs, OMx OLx bits)
- Clear Flag (TFLG1 reg)
- Enable int (TMSK1 reg)
- In interrupt service routine
- Set time for next action to occur (write TCx reg)
- For periodic events add time to TCx register
- Clear flag (TFLG1 reg)
Bill Rison
2001-03-01