USING INPUT CAPTURE 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 IC (TIOS reg)
- (d)
- Set edge to capture (TCTL 3-4 regs)
- (e)
- Clear Flag (TFLG1 reg)
- (f)
- Enable Int if using (TMSK1 reg)
- 2.
- In interrupt service routine (or main program if not using interrupts):
- (a)
- Read time of edge from TCx
- (b)
- Clear flag (TFLG1 reg)