Skip to main content
imalamoud
Associate II
September 30, 2016
Question

Sine wave generator using DAC - how to obtain exact results?

  • September 30, 2016
  • 1 reply
  • 694 views
Posted on September 30, 2016 at 18:14

Hello,

I am trying to create sine wave generator using DAC and DMA based on STM32L476.

The goal is to obtain exactly 100KHZ, 10KHZ frequencies with maximum possible number of samples.

Thus I have set APB timer for DAC to 72MHZ, timer period to 15 and sample sizes to 48 for 100kHz and 480 for 10kHz.  This combination gives ideal frequency results.

However I need more than 480 samples for 10Khz.

If the sample pool is set to say 800, timer period to 9 then the result frequency is never exact there is en error of 1-2%. 

Why is that? Does the DAC/Timer combination require some special timing considerations?

    This topic has been closed for replies.

    1 reply

    Tesla DeLorean
    Guru
    September 30, 2016
    Posted on September 30, 2016 at 19:58

    Period is normally an N-1 value, if you set it to 15 (0..15) it is dividing by 16. 72000000/16 = 4500000, 72000000/10 = 720000

    Show your code, it is a lot easier than guessing.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..