I am trying to get the pwm working on the Atmel Xmega256A3BU. I am not getting the desired PWM on the port pin. Here's my initialization for the PWM generation in the code.
void pwm_init()
{
PORTC_DIR = 0x01; //Set PC.0 as the output port
TCC1_PER = 0xFFFF; //Set the period of the waveform
TCC1_CTRLB |= 0x03; //Single slope mode
TCC1_CTRLB |= 0x10; //channel selection CCAEN
TCC1_CTRLA |= 0x02; //clock selection clk/2
}
void main( void )
{
pwm_init();
TCC1_CCABUF = 0x7FFF; //set the duty cycle as 50%
while((TCC1_INTFLAGS & 0x01) == 0); //wait for the new compare value to be loaded
TCC1_INTFLAGS = 0x00; //clear the interrupt flag
while(1);
}
Here, I have just provided the snippet of my code which is running at 32MHz. So what else am I missing here ? Any help would be much appreciated. I am doing this in the AVR IAR workbench. So if anyone can share your PWM code that would be helpful too.