Description: This example shows how to configure TC in waveform and capture mode. In capture mode, pulse signal is set as an input, RA and RB will be loaded when programmed event occurs. When TC interrupt happens, we could read RA and RB value for calculating pulse frequency and pulse number be increased. The current pulse frequency and total pulse number is output on DBGU. The code can be roughly broken down as follows:
- Select pre-defined waveform frequency and duty cycle to be generated.
- Configure TC channel 1 as waveform output.
- Configure TC channel 2 as capture input.
- Configure capture Register A be loaded when rising edge of TIOA occurs.
- Configure capture Register B be loaded when failing edge of TIOA occurs.
- Configure an interrupt for TC and enable the RB load interrupt.
- 'c' start capture.
- 's' will stop capture,and dump the informations what have been captured.