cancel
Showing results for 
Search instead for 
Did you mean: 

sine generator per AN3126

dickb_100
Associate
Posted on September 08, 2014 at 03:06

I'm using an STM32F439 up clocked at 168 Mhz. I want to generate a sine wave exactly as outlined in app note AN3126 but I have several questions.

1) In the App note paragraph 2.1.3 it talks about the frequency of the resultant generated waveform and gives formula and example. Am I missing something ??? If my clock is at 1 Mhz ( a 1000 Khz ) and there are 10 samples in the waveform it seems to me that the output waveform should be 100 Khz not 10 Khz as stated in the text.

2) my goal is to generate sine waveform up to as high as 2.0 Mhz assuming for a second that I have 10 samples / 360 degrees of waveform  I need to clock the DAC and DMA at 20 Mhz which I believe is within all timing specifications and capabilities. Hopefully someone can verify that. but I do have a problem with the resolution available with this scheme at high output frequencies. As an example if I set a divisor of 8 in my timer then my output clock is at 168/8=

21.0 Mhz and at 10 samples/ 360 degrees of waveform my output frequency is 2.1 Mhz.

 the next possible divisor is 9 which yields a output waveform of  1.86 Mhz and a change of  a liitle over 11 % in frequency. Does anyone have a clever way to achieve much finer resolution than 11 %. Is it possible to cascade 2 timers to achieve this as a coarse divisor and a fine divisor?

#aribtary-waveform #sine-waveform
1 REPLY 1
zzdz2
Associate II
Posted on September 08, 2014 at 07:57

You don't need to use single cycle buffer, you can use 21 samples of 2 cycles, i.e. 10.5 samples per cycle.

Of course you could use even bigger sample buffer.