timer_example_debug.c File Reference

#include "timer.h"
#include "../usart/usart.h"
#include "../debug/print_funcs.h"
#include "../pio/pio.h"

Include dependency graph for timer_example_debug.c:

Go to the source code of this file.

Defines

#define CLEAR   2
#define CPU_HZ   20000000
#define FALSE   0
#define NOOP   0
#define SET   1
#define TOGGLE   3
#define TRUE   1

Functions

int main (int argc, char *argv[])
void timer_delay (void)


Define Documentation

#define CLEAR   2
 

Definition at line 13 of file timer_example_debug.c.

#define CPU_HZ   20000000
 

Definition at line 6 of file timer_example_debug.c.

#define FALSE   0
 

Definition at line 18 of file timer_example_debug.c.

#define NOOP   0
 

Definition at line 11 of file timer_example_debug.c.

#define SET   1
 

Definition at line 12 of file timer_example_debug.c.

#define TOGGLE   3
 

Definition at line 14 of file timer_example_debug.c.

#define TRUE   1
 

Definition at line 17 of file timer_example_debug.c.


Function Documentation

int main int  argc,
char *  argv[]
 

Definition at line 22 of file timer_example_debug.c.

References timer_waveform_opt_t::acpa, timer_waveform_opt_t::acpc, timer_waveform_opt_t::aeevt, timer_waveform_opt_t::aswtrg, timer_waveform_opt_t::bcpb, timer_waveform_opt_t::bcpc, timer_waveform_opt_t::beevt, timer_waveform_opt_t::bswtrg, timer_waveform_opt_t::burst, timer_waveform_opt_t::channel, CLEAR, timer_waveform_opt_t::clki, timer_waveform_opt_t::cpcdis, timer_waveform_opt_t::cpcstop, CPU_HZ, timer_waveform_opt_t::eevt, timer_waveform_opt_t::eevtedg, timer_waveform_opt_t::enetrg, FALSE, NOOP, SET, timer_waveform_opt_t::tcclks, TIMER_CLOCK_SOURCE_TC5, timer_delay(), timer_init_waveform(), timer_read_tc(), timer_start(), TIMER_WAVEFORM_SEL_UPDOWN_MODE, timer_write_ra(), timer_write_rb(), timer_write_rc(), and timer_waveform_opt_t::wavsel.

00023 {
00024 
00025   struct timer_waveform_opt_t waveform_opt;
00026   struct usart_options_t usart_opt;
00027   
00028   avr32_pio_t *piob = (void *) AVR32_PIOB_ADDRESS;
00029   avr32_usart_t *usart = (void *) AVR32_USART1_ADDRESS;
00030   
00031   avr32_piomap_t usart_piomap = {                          \
00032     {AVR32_USART1_RXD_0_PIN, AVR32_USART1_RXD_0_FUNCTION},  \
00033     {AVR32_USART1_TXD_0_PIN, AVR32_USART1_TXD_0_FUNCTION}   \
00034   };
00035   
00036   /* The channel number and instance is used in several functions */
00037   /* It's defined as local variable for ease-of-use causes */
00038   int channel = 1;
00039   int timer_instance = 1;
00040   
00041   /* Enable Timer module on PIOB */
00042   piob->pdr = 0x0003ffff;
00043   piob->asr = 0x0003ffff;
00044   
00045   /* Options for Waveform genration */
00046   waveform_opt.channel = channel;
00047   waveform_opt.tcclks = TIMER_CLOCK_SOURCE_TC5;
00048   waveform_opt.clki = FALSE;
00049   waveform_opt.burst = FALSE;
00050   
00051   waveform_opt.cpcstop = FALSE;
00052   waveform_opt.cpcdis = FALSE;
00053   waveform_opt.eevtedg = FALSE;
00054   waveform_opt.eevt = 0;
00055   waveform_opt.enetrg = FALSE;
00056   waveform_opt.wavsel = TIMER_WAVEFORM_SEL_UPDOWN_MODE;
00057   
00058   waveform_opt.acpa = SET;
00059   waveform_opt.acpc = CLEAR;
00060   waveform_opt.aeevt = NOOP;
00061   waveform_opt.aswtrg = NOOP;
00062   
00063   waveform_opt.bcpb = NOOP;
00064   waveform_opt.bcpc = NOOP;
00065   waveform_opt.beevt = NOOP;
00066   waveform_opt.bswtrg = NOOP;
00067   
00068   /* Options for USART debugging */
00069   usart_opt.baudrate = 115200;
00070   usart_opt.charlength = 8;
00071   usart_opt.paritytype = USART_NO_PARITY;
00072   usart_opt.stopbits = USART_1_STOPBIT;
00073   usart_opt.channelmode = USART_NORMAL_CHMODE;
00074   
00075   /* Initialize it in RS232 mode */
00076   pio_enable_module(usart_piomap, 2);
00077   usart_init_rs232(usart, &usart_opt, CPU_HZ);
00078  
00079  print(usart, "Timer / Counter test...\n");
00080 
00081   /* Init the Timer */
00082   timer_init_waveform(timer_instance, &waveform_opt);
00083   timer_write_ra(timer_instance, channel, 0x0055 );
00084   timer_write_rb(timer_instance, channel, 0x00aa );
00085   timer_write_rc(timer_instance, channel, 0x00ff );
00086   timer_start(timer_instance, channel);
00087   
00088   while(1){
00089     printf("TC: 0x%x \n", timer_read_tc(timer_instance,channel) );
00090     timer_delay();
00091   }
00092   return 0;
00093 }

Here is the call graph for this function:

void timer_delay void   ) 
 


Generated on Mon Jun 19 15:12:27 2006 for AVR32110 Using the AVR32 Timer/Counter by  doxygen 1.4.6