0
$\begingroup$

I'm generating samples for dac in STM32. sin(2pii /N)*4096/2. This is the formula I'm using. How to I come to know sampling frequency? Whether sampling frequency comes into picture?

$\endgroup$
3
  • $\begingroup$ To know the sampling frequency in units of samples/second, you would need to know the frequency of your sine wave in Hz. I assume i is your counting index? Write out the formula for a sine wave and consider how you set the frequency of the sine wave with that and this should all be clearer to you. $\endgroup$ Commented Jun 17, 2021 at 12:03
  • $\begingroup$ I want to generate a sine signal with 1KHz frequency. $\endgroup$
    – user653241
    Commented Jun 17, 2021 at 12:20
  • $\begingroup$ Ok. What sampling rate do you want to use? And are you familiar with Nyquist's Theorem? If not this should help you: users.cs.cf.ac.uk/Dave.Marshall/Multimedia/node149.html $\endgroup$ Commented Jun 17, 2021 at 12:28

1 Answer 1

0
$\begingroup$

How to I come to know sampling frequency?

That is part of initializing your DAC. You need to read the documentation and look at the setup code for your DAC and DMA (if applicable)

Whether sampling frequency comes into picture?

Everything in Digital Signal Processing is relative to the sample rate. A sine wave is generated as

$$x[n] = sin(2\pi \frac{f_0}{f_s} \cdot n)$$

where $f_0$ is the frequency of your sine wave and $f_s$ your sample rate.

$\endgroup$
2
  • $\begingroup$ Thanks Hilmer. If DAC has resolution 12 and reference voltage is 3.3 for 1K signal frequency and 10K sampling frequency ,what would be the peak to peak voltage of sine ? Vref comes into picture? Or I only get "A" (amplitude of sine =1V)? $\endgroup$
    – user653241
    Commented Jun 17, 2021 at 13:58
  • $\begingroup$ I recommend reading the data sheet of the DAC $\endgroup$
    – Hilmar
    Commented Jun 17, 2021 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.