Problem in using timers of AT32UC3C0512C

Started by simp...@hotmail.com May 7, 2013
I have been trying for days now to configure the timers of AT32UC3C0512C to
generate a simple square wave. I am sure that the clock is reaching the timer
module, but there is no output. I am posting my code here. Can someone please
help me on this? Its been a long while since I am doing this and continuously
being unsuccessful. I am trying to generate a left aligned pulse with a
considerable duty cycle in this code. Ra compare is set to 0 so the pulse should
be high from the start and should remain high until the counter is lower than Rc
compare. Since Rc compare value is a large one almost equal to the max value
achieved by a 16 bit register, so the duty cycle is supposed to be high. Here is
my code:

void timer_initialize (void)
AVR32_TC0.channel[0].ccr = 0x00000001;
AVR32_TC0.channel[0].cmr =0x00018004; //ra compare effect only
AVR32_TC0.channel[0].ra = 0x00000000;
AVR32_TC0.channel[0].rc = 0x00007FFF;
AVR32_TC0.bcr = 0x00000000;
AVR32_TC0.bmr = 0x00000015;

int main (void)

e Power manager and SCIF for 64MHz CPU frequency

//Enable OSC0
AVR32_SCIF.unlock = 0xAA000000 | AVR32_SCIF_OSCCTRL; //unlock oscctrl register
AVR32_SCIF.oscctrl[0] = 0x00010001; //enable osc0
while ( !(AVR32_SCIF.pclksr & 0x1) ); //wait for oscctr0 to lock again until we

// Enable PLL0 = 66Mhz, wait for it to lock
AVR32_SCIF.unlock = 0xAA00001C;
AVR32_SCIF.pll[0] = 0x3F0F0119;
while ( !(AVR32_SCIF.pclksr & 0x10) );

// Enable PLL1 = 132Mhz, wait for it to lock
AVR32_SCIF.unlock = 0xAA000020;
AVR32_SCIF.pll[1] = 0x3F0A0109;
while ( !(AVR32_SCIF.pclksr & 0x20) );

// Set a wait state since Fcpu > 33MHz
AVR32_FLASHC.FCR.fws = 1;

// Enable PLL0 as the system clock source
AVR32_PM.unlock = 0xAA000000;
AVR32_PM.mcctrl = 3;

//Select the PBC frequency
AVR32_PM.unlock = 0xAA000014;
AVR32_PM.pbcsel = 0x00000087;

//peripheral functions enabled for GPIO pin TC0_A0 corresponding to PB19
AVR32_GPIO.port[1].gper = 0xFFF7FFFF;
AVR32_GPIO.port[1].oder = 0xFFFFFFFF;
AVR32_GPIO.port[1].pmr0 &= 0xFFF7FFFF;
AVR32_GPIO.port[1].pmr1 &= 0xFFF7FFFF;
AVR32_GPIO.port[1].pmr2 &= 0xFFF7FFFF;


return 0;