Repairing an AVR DDS Signal Generator
Background
As far as I can tell, the first use of an AVR to do direct digital synthesis of an analog signal was by Jesper Hansen in 2001. Mindaugas Marozas picked up the idea to create a stand-alone function generator in 2006. In 2008, Mindaugas published an improved version, which has become the basis of many homebrew projects, as well as a number of Chinese clones. Georg Latzel, DL6GL, gives a very nice and detailed rundown of the theory of operation (in German).
What I learnt today...
… is that on the AVR, the “Data Memory Usage” information given by AVRGCC only refers to memory allocated at compile time, and does not take the stack into account. The stack is not to be underestimated: it holds not only the return addresses from function calls, but also all local variables of the function(s) called.
So you might feel safe and sound reading something like “Data Memory Usage : 66 bytes 51,6% Full”, thinking there’s plenty of space left for future features; and then the stack still swoops down and corrupts your precious data because of a couple of nested function calls.