samEEEf
Full Member level 2
I need to generate 100Hz PWM from internal Clock (1Mz) of ATmega8. But unable to do. TOP value at ICR1 is not working. It generates constant frequency and I'm unable to change the frequency by changing TOP value. I can change the duty cycle by changing OCR1 value.
Here is the code
Could anybody help me on this regards...
Here is the code
Code:
//Set OC1A on Compare Match, clear OC1A at BOTTOM, (inverting mode)
//Fast PWM mode , Pre scaler 1
int pwm16(void){
TCCR1A|=(1<<COM1A1)|(1<<COM1A0)|(1<<WGM11) ;
TCCR1B|=(1<<WGM12)|(1<<WGM13)|(1<<CS00);
ICR1=0x2710;
OCR1A=60;
return 0;
}
Could anybody help me on this regards...