Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] ATtiny2313 audio

2009-12-28 by Marc R.J. Brevoort

On Sun, 27 Dec 2009, Leon Heller wrote:

>> I'd like to try polyphonic audio now- still using
>> simple square waves. Is the 2313 simply too slow
>> for the task?

> I've generated sine waves using a software DDS up
> to 200 kHz or so, with a 12 MHz Tiny2313.

All right, that pretty much answered the question
('The ATtiny2313 should be able to cope just fine').
Apparently I had selected the wrong prescaler value.

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).

This does give me a high enough sample rate,
and I'm managing to get polyphonic sound -
BUT it also implies that my understanding of the
prescaler and timers is still wrong, as by my
understanding this would mean to have an interrupt
roughly every clock cycle (which would leave
absolutely no time for any calculations).

If anyone could clue me in about what am I missing,
I'd be very grateful!

Best,
Marc

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.