Bluestar88
Member level 3
- Joined
- Oct 17, 2014
- Messages
- 59
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 6
- Activity points
- 447
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...