With the AVR it is common when implementing an 8-Bit fixed Sinewave Generator, to use an 2^8 sized lookup table to hold the SineWave values. With this SinDac
program we plan to use the same convention on the ARM-F4 ---- a 12-Bit fixed Sinewave Generator using an 2^12 sized lookup table.
We wish to generate a Dual ouput SineWave in Anti-Phase using both channels of the DAC and that means each value to be output contains 32-Bits arranged so:
00xxxxxx00yyyyyy; where xxxxxx = Channel_2 DAC output and yyyyyy = Channel_1 DAC output. The 4 MS-Bits must be set to default zeros. We firstly precalculate
the Channel_1 value using the Sine function Ch1=2047+(2047*(Sin(N*Pi*2/4096))) ; courtesy of Atmel App note AVR314. The Channel_2 value is obtained using
Ch2= (4095-S)*65536 and both 12-Bit channel values are OR'ed together to form a single 32-Bit word. This step is repeated 4096 times and the associated table is to be
found in the attached SinTab.inc.
Dual Sinewave Anti-Phase Output @ 2,560 Hz.
Waveform Parameters of the Dual signals.
This routine is fully Software driven, so as to show more clearly the basic structure of the program. Using the DMA Peripheral to move the data from Flash directly
to the DAC Peripheral should markedly speed up the data transfer and free up the cpu for more urgent tasks.
" If what you are getting online is for free, you are not the customer, you are the product! " Jonathan Zittrain.