Yahoo Groups archive

AVR-Chat

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

Message

Re: [AVR-Chat] Re: ATtiny2313 audio- w/source

2009-12-29 by Leon Heller

----- Original Message ----- 
From: "Marc R.J. Brevoort" <mrjb@dnd.utwente.nl>
To: <AVR-Chat@yahoogroups.com>
Sent: Tuesday, December 29, 2009 9:02 PM
Subject: Re: [AVR-Chat] Re: ATtiny2313 audio- w/source


> Hi Donald,
>
>> Please understand the basics of what you want to do, then code.
>> I think this may help you.
>> http://www.avr-asm-tutorial.net/avr_en/AVR_DAC.html
>
> Thanks for the link. Unfortunately it has little to do with my main
> issue, which was about how to write timer-based, interrupt-driven
> code for the AVR in C. The actual signal generation (as described
> in the above article) is the easy part!
>
> I find it interesting, however, that the code on the page you mentioned
> seems to have limits similar to the ones I have been running into:
> 1800Hz for a 256-sample sine wave at a 4MHz clock speed translates to
> roughly 61 cycles per sample, which does not leave a lot of room for
> anything else. (In an interrupt-driven solution, a few more cycles are
> burnt to preserve machine state).
>
> It does leave me curious about how Leon managed to generate 200kHz
> sine waves on a 12 MHz AVR- that would seem to only leave 30 cycles
> per sample (and at that point the signal would really be a square wave
> rather than a sine wave).
>
> Unless there was some other hardware-assisted trick at work there.
> The question is if that 'trick' would be of any help for polyphonic
> audio.
>
> Leon, care to comment?

The code is here:

http://webspace.webring.com/people/jl/leon_heller/dds.html

I've got a similar program that is interrupt-driven, avoiding glitches when 
the frequency is changed.

Leon

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.