- Fri Nov 12, 2010 9:37 am
#113306
Hi, I know that this has been covered a lot, but I just can't seem to understand.
I am trying to generate phone-quality(8bit 8khz sampling rate) sound using an atmega32 running at 16mhz.
I was tinking about using Timer0 (8bit) for that.
Technically, All I would need to do is setup the timer correctly and write to OCR0 on every TIMER0_OVF interupt right?
I am using the Fast PWM mode and If I am using a prescaller of 8, my frequency will be 16MHZ/8/TOP=7812hz. Which is not 8KHZ
I have seen somewhere that I could use a prescaler of 8 and set TOP to 250. But how do I set TOP=250?
Another place suggested to use the OCR0 to limit TOP, but that is not possible when in fast PWM mode since OCR0 is used to drive the OC0 pin.
I am trying to generate phone-quality(8bit 8khz sampling rate) sound using an atmega32 running at 16mhz.
I was tinking about using Timer0 (8bit) for that.
Technically, All I would need to do is setup the timer correctly and write to OCR0 on every TIMER0_OVF interupt right?
I am using the Fast PWM mode and If I am using a prescaller of 8, my frequency will be 16MHZ/8/TOP=7812hz. Which is not 8KHZ
I have seen somewhere that I could use a prescaler of 8 and set TOP to 250. But how do I set TOP=250?
Another place suggested to use the OCR0 to limit TOP, but that is not possible when in fast PWM mode since OCR0 is used to drive the OC0 pin.