Introduction
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 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. Use an oscilloscope to probe the TC channel's output pin.
- Note
- On the AT32UC3A0512, the output pin TIOA0 is mapped on PB23.
- On the AT32UC3B0256, the output pin TIOA0 is mapped on PB00.
- On the AT32UC3A3256, the chosen output pin TIOA0 for the Timer/Counter 0(TC0) is mapped on PB05.
- On the AT32UC3L064, the chosen output pin TIOA0 for the Timer/Counter 1(TC1) is mapped on PB00 (with the STK600 + RCUC3L0 routing card, PB00 is routed to STK600.PORTD.PD0).
- On the ATUC128D3, the chosen output pin TIOA0 for the Timer/Counter 1(TC0) is mapped on PB00 (with the STK600 + RCUC3D routing card, PB00 is routed to STK600.PORTE.PE01).
- On the AT32UC3C0512, the chosen output pin TIOA0 for the Timer/Counter 0(TC0) is mapped on PB19.
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%.
-
According to datasheet, TIMER_CLOCK3 is equal to (clk_pba/8). Since we switch the main CPU clock to OSC0 (=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).
Main Files
Compilation Info
This software was written for the GNU GCC for AVR32 and IAR Systems compiler for AVR32. Other compilers may or may not work.
Device Info
All AVR32 devices with a TC module can be used. This example has been tested with the following boards:
- EVK1100 evaluation kit with an AT32UC3A0512 MCU.
- EVK1101 evaluation kit with an AT32UC3B0256 MCU.
- EVK1104 evaluation kit with an AT32UC3A3256 MCU.
- STK600 + RCUC3L0 routing card with an AT32UC3L064 MCU.
- STK600 + RCUC3D routing card with an ATUC128D3 MCU.
- AT32UC3L-EK evaluation kit with an AT32UC3L064 MCU.
- AT32UC3C-EK evaluation kit with an AT32UC3C0512C MCU.
Setup Information
CPU speed: 12 MHz.
Contact Information
For further information, visit Atmel AVR32.