Re: [booksbybibin,www.booksbybibin.tk] Problem in programming the Timers?
you have to use timer/counter(n) register. this is ATMEGA8535's PWM duty cycle 50%example program. you can write like this.
TCCR1A = 0X83;
TCCR1B = (1<<CS11); // | (1<<CTC1); /* setup the CK/8 frescalar */
OCR1AH=0X02; // using for output PWM OCCR1A
- --- In firstname.lastname@example.org, "joinmahsan" <joinmahsan@...> wrote:
> I am having problem in programming the timer of ATmega16 in
> compare mode. I am trying it with AVRGCC in AVR studio. Some one give
> any idea or example of programming compare mode of any timer to create
> a PWM as output.
i write in AVR studio 4.14 and WinAVR 20080430, use timer in Phase
corect PWM mode. watch in this link for example. have fun !!!
you have to use timer/counter(n) register. this is ATMEGA16's PWMthere are alltogether 4 pwm portsOC0- PB3OC1A- PD4OC1B- PD50C2- PD7FOR duty cycle X %example program. you can write like this.TCCRX=OXVV ; // VV YOU HAVE TO SET FROM DATA SHEET NORMALLY IT IS 0X6B;IN COMPARE MODE
OCRX = 0XUU; //UU=255* X%