AVR32 - Cycle Counter Driver Documentation
This documents gives an example of the usage of the CPU Cycle counter. The cycle counter is a COUNT register, that increments once every clock. The count register can be used together with the COMPARE register to create a timer with interrupt functionality. The COMPARE register holds a value that the COUNT register is compared against. When the COMPARE and COUNT registers match, a compare interrupt request is generated and COUNT is reset to 0.
This example shows how to use the COUNT register together with the COMPARE register to generate an interrupt periodically. Here is the operating mode of the example:
- At the beginning of the code, we check that initial default values of the COUNT and COMPARE registers are correct.
- Then, the COUNT & COMPARE interrupt mechanism is tested with a short delay. Messages are displayed on USART1. This delay is equal to (1/fCPU)*NB_CLOCK_CYCLE_DELAY_SHORT in case NB_CLOCK_CYCLE_DELAY_SHORT value is reloaded (83.3ms) or (1/fCPU)*NB_CLOCK_CYCLE_DELAY_LONG in case NB_CLOCK_CYCLE_DELAY_LONG value is reloaded (1.67s)
- Then the program infinitly loops, using the COUNT & COMPARE interrupt mechanism with a longer delay. Messages are displayed on USART1 and one of Led 1 through Led4 is on upon each COUNT & COMPARE match (Led1 -> Led2 -> Led3 -> Led4 -> Led1 ...and so on).
- cycle_count_example.c : cycle counter example
- cycle_counter.h: cycle counter driver interface
This software was written for the GNU GCC for AVR32 and IAR Systems compiler for AVR32. Other compilers may or may not work.
This example has been tested with the following configuration:
- EVK1100, EVK1101, EVK1104, EVK1105, AT32UC3C-EK or AT32UC3L-EK evaluation kits; STK600+RCUC3L routing card;
- CPU clock: -- EVK1100, EVK1101, EVK1104, EVK1105, AT32UC3L-EK, STK600+RCUC3L : 12 MHz; -- AT32UC3C-EK : 16 MHz
- USART1 (on EVK1100 or EVK1101) connected to a PC serial port via a standard RS232 DB9 cable, or USART0 (on EVK1105) or USART1 (on EVK1104) or USART2 (on AT32UC3C-EK) abstracted with a USB CDC connection to a PC or USART3 (on AT32UC3L-EK) abstracted with a USB CDC connection to a PC; STK600 usart port for the STK600+RCUC3L setup (connect STK600.PE2 to STK600.RS232 SPARE.TXD and STK600.PE3 to STK600.RS232 SPARE.RXD)
- PC terminal settings:
- 57600 bps,
- 8 data bits,
- no parity bit,
- 1 stop bit,
- no flow control.
For further information, visit
Atmel AVR32.
Support and FAQ:
http://support.atmel.no/