I wanted to use timer 1 as PWM Phase and Frequency Correct (ICR1 as top)
My question is can I change top each time I turn on timer like in the code below?
Data sheet warns about changing ICR1 while timer is running but when it is stopped, set and then turned on could it be save. How ICR1 is updated? immediately?
Anyway I post this question because in Proteus VSM software some of the frequencies don`t appear on OC1B and OC1A pins. In AVRStudio they seems to work.
I think I should start debug it on real chip.
TCCR1B|= (1<<WGM13); //ICR1 as TOP //Turn on target_timer_count=F_CPU/(frequency_A) + 1; ICR1= target_timer_count; //Top OCR1A= (target_timer_count * 5/ 10); OCR1B= (target_timer_count * 9/ 10); TCCR1A|= (1<<COM1A1)|(1<<COM1B1); TCCR1B|= (1<<CS10); //Turn off TCCR1A&=~(1<<COM1A1); TCCR1A&=~(1<<COM1B1); TCCR1B&=~((1<<CS12)|(1<<CS11)|(1<<CS10)); TCNT1=0x00;
PS. I use atmega 8 and avrstudio 4.19