Marc R.J. Brevoort wrote:
> I had set the prescaler to 256, assuming this would
> result in a timer of 8MHz/256=31250 Hz, and set
> TCNT0 to 254 (one overflow every 2 ticks, or roughly
> 15625 times per second) which would give me approx.
> 512 cycles to calculate the wave.
>
> Right now, I've set:
>
> TCCR0B to 0<<CS02|0<<CS01|1<<CS00 (no prescaling)
> and
> TCNT0 to 255 (overflow on next tick)
> and
> TIMSK=(1<<TOIE) (enable counter overflow int).
For one interrupt every 1/31250Hz, I'd use:
TCCR0A = 1<<WGM1 (CTC mode)
TCCR0B = 1<<CS01 (8MHz/8)
OCR0A = ((8MHz/8)/31250Hz)-1 = 32-1
TIMSK = 1<<OC1E0A
TCNT0 = don't care
Mark JordanMessage
Re: [AVR-Chat] ATtiny2313 audio
2009-12-28 by enkitec@gmail.com
Attachments
- No local attachments were found for this message.