Bluestar88
Member level 3
![Member level 3](/styles/images/ranks/dlevel3.gif)
Hi guys,
I woud like to produce a pulse with 200 HZ frequency and 0.07 duty cycle, so I used timer2 of atmega32 in FAST PWM mode.
For this purpose, I used external crystal 4MHZ, and Prescale 128 (FOR 200Hz). basis on fpwm=crystal/(prescale*(256-tcnt)) formula, I computed 100 (0x64) for TCNT2, For duty cycle 0.07, according to dutycycle=ocr2/(256-tcnt2) formula, OCR2 is 0x68.
So I did it in Codevision:
TCCR2=0x6D;
TCNT2=0x64;
OCR2=0x68;
But I coudnot get to 200 Hz, it is about 125 Hz...please help me...
I woud like to produce a pulse with 200 HZ frequency and 0.07 duty cycle, so I used timer2 of atmega32 in FAST PWM mode.
For this purpose, I used external crystal 4MHZ, and Prescale 128 (FOR 200Hz). basis on fpwm=crystal/(prescale*(256-tcnt)) formula, I computed 100 (0x64) for TCNT2, For duty cycle 0.07, according to dutycycle=ocr2/(256-tcnt2) formula, OCR2 is 0x68.
So I did it in Codevision:
TCCR2=0x6D;
TCNT2=0x64;
OCR2=0x68;
But I coudnot get to 200 Hz, it is about 125 Hz...please help me...