Thanks a million to Jesper Hansen, whose pioneering work with AVR DDS-Generators so influenced my own AVR assembler development :-)
This port of his Mini-DDS program onto the F4 provides a simple demonstration of how easy it is to reuse a significant amount of the assembly code, already
written for the 8-bit AVR, in a 32-bit ARM environment. In order to follow the code structure and flow of the DdsGen program, it is highly recommended to read through
Jesper's code first. A really good, clear and concise DDS tutorial, which goes in depth into the nitty gritty of these systems, is available here from Analog Electronics.
Once, having grasped the basic principles underlying the Direct Digital Synthesis (DDS) algorithm, the similarities between both code versions will
become clearer. We followed the layout of Jesper's code almost slavishly. Since both the AVR and ARM are risc processors, it's fairly simple to translate from one into
the other. One of the major differences between both DDS implementations, lies in the fact, that we chose to use a 32-bit Delta-Phase Accumulator for the F4 instead
of the 24-bit version used in the AVR. This has the advantage of allowing a future upgrade to a 12-bit / 4096 sample system in contrast to the current 8-bit / 256 sample
version. And last but not least, the ARM version presented here outputs a Dual anti-phase Waveform unlike the AVR version, which generates a Mono phase output
instead. Though, what's above all missing in the ARM version, is the lack of a suitable input medium to allow us to alter the frequency on the fly, as it were. But this
program is more about encouraging AVR freaks to take a leap of faith into the realm of programming the ARM in it's mother tongue ;-) So the desired frequency has
to be simply entered by hand using the Delta equate in Start according to the corresponding formula:
f = Delta * f_Clock
f_Clock is in this case the CPU clock divided by the number of cycles to output the data ( 20 cycles )
f = Delta * ( 168000000 / 20 ) / 2^32
f = Delta * 0.0019557774
Delta = f * 511.306
Suppose we wish to generate a SineWave of 1 Khz, then Delta = Int ( 1000 * 511.306 ) = 511306
Some interesting captured Waveform Parameters of the above signals.
Operating the device is really child's play. On power up the default Blue led lights up and we can see a nice Sinewave on the scope. Depress and release the
User-Button once and we can see now the Green led coming on and the waveform changes to a SawToothWave. Hit the button again, and this time we can observe
both the Orange led and a TriangleWave to boot. With the next button sequence it's a Red led in conjunction with a SquareWave. And the whole process loops back
to Blue / SineWave with the next button operation! Finally it should be noted, that the maximum, usable output clock frequency corresponds to around 100 Khz.
" No event ever, ever justifies a negative feeling! " Tony de Mello.