This is the documentation for the data structures, functions, variables, defines, enums, and typedefs for the TC driver.
It also gives an example of the usage of the TC module.
This example involves 2 timer/counter channels, one configured in capture mode (input) and the other configured in waveform mode (output) to generate a PWM on the output.
Channel 1 of a timer/counter module is used with the input pin TIOA1. You will find the port and pin number in the datasheet of your device. The selected timer input clock is the internal clock labelled TC4 referred to as TIMER_CLOCK4 in the datasheet.
Channel 0 of a timer/counter module is used with the output pin TIOA0. You will find the port and pin number in the datasheet of your device. The selected timer input clock is the internal clock labelled TC3 referred to as TIMER_CLOCK3 in the datasheet.
The 16-bit input timer/counter channel will cycle from 0x0000 to 0xFFFF or until a falling edge is detected on the input pin, in which case the counter is captured in RA before being reset then started with the same rules. Consequently, RA is a measure of the input period modulo 16 bits.
The 16-bit output timer/counter channel will cycle from 0x0000 to 0xFFFF, starting at 0x0000 with a high output pin level and lowering the output pin level when it reaches the value of RA extracted from the input timer/ counter while raising the output pin level when it reaches the value of RC left at 0. This will hence produce a PWM output signal with a duty cycle depending on the period of the input signal.
This software was written for the GNU GCC for AVR32 and IAR Systems compiler for AVR32. Other compilers may or may not work.
All AVR32 devices with a TC module can be used. This example has been tested with the following board:
CPU speed: 12 MHz.
For further information, visit Atmel AVR32.