AVR32 AP7 - TC Driver Documentation
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 will start a timer/counter and generate a PWM on the output.
Channel 0 of timer/counter module 0 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. Use an oscilloscope to probe the TC channel's output pin.
- Note:
- On the AT32AP7000, the output pin TIOA0 is mapped on PA12. Which on the STK1000 is available on J31 pin 4 by setting the jumper SW2 to enable TIMER0.
The 16-bit timer/counter value register (CV) will cycle from 0x0000 to 0xFFFF. The chosen channel with a low output pin level upon starting point (i.e. when CV == 0) will toggle the output pin level when it reaches the values 0x0300 and 0x1000. This will hence produce a PWM output signal with a duty cycle of (0x2000 - 0x600) / 0x10000, i.e. 10.16%.
- Note:
- According to datasheet, TIMER_CLOCK3 is equal to (clk_pbb/8). Since we adjust PLL and divider to get PBB speed of 12MHz, we have TIMER_CLOCK3 == 1.5 MHz.
According to the settings performed by the application, the output waveform should thus have the following properties:
- The period of the waveform will thus be 1500000 / 65536 = 22.9 Hz.
- A full duty cycle (just toggling the channel's output pin when CV reaches 0xFFFF and passes to 0x0000) thus lasts 43.7 ms (65536 / 1500000). A duty cycle of 10.16% means that when probing the channel's output pin you should see a duty cycle of ~4.4 ms (10.16% of 43.7 ms).
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 boards:
CPU speed:
20 MHz.
For further information, visit
Atmel AVR32.
Support and FAQ:
http://support.atmel.no/