cancel
Showing results for 
Search instead for 
Did you mean: 

DAC for sweeping frequency of Sine wave

manoritesameer
Associate II
Posted on March 28, 2014 at 16:42

I want to generate sine wave (single cycle) and then change the frequency using DAC.

basically Sweep the frequency... How would I do that.

Thanks for your help in advance.    

#stm32f4
6 REPLIES 6
Posted on March 28, 2014 at 16:51

Have a SINE wave table driven out the DAC using a TIM/DMA trigger combination, and then alter the frequency of the TIM timebase.

You could also play games with the wave table buffer, and have that output.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
chen
Associate II
Posted on March 28, 2014 at 16:55

Hi

Basically, generate a 'wave table' - just the sine wave values in a 1d array.

Set up the DAC, make sure the output goes to 1 IO pin.

Set up the IO pin as analgue function.

Select a DAC clocking/speed to generate the sine wave at required frequency.

Pass the wave table to the DAC using DMA.

Change the DAC output clocking speed to change the freq.

Search the forum. This has been covered a number of times.

clive1 has probably provided some code.

If you want the output to drive, say a speaker the IO pin does not have enough current capability. It will need an amplifier of some kind (transistor or op-amp).

It is OK for looking at on a scope or pass into input stage of some other silicone device.

manoritesameer
Associate II
Posted on March 28, 2014 at 21:30

Thanks for the prompt  reply.As you have suggested, I have already done that, just that I want to generate only one cycle of sine wave for each frequency. How would I do that . Also a small code would be a great help. 

Posted on March 28, 2014 at 21:37

I want to generate only one cycle of sine wave for each frequency. How would I do that.

Program the DMA in normal mode rather than circular mode.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
manoritesameer
Associate II
Posted on March 28, 2014 at 23:30

Again thank you, yes it does produce one cycle, but the sweep does not work with the DMA in normal mode. Do I need to configure something. I mean when the next time I change the value of the timer counter the DMA does not provide sine wave data to the DAC.

Posted on March 28, 2014 at 23:34

I don't understand what ''sweep'' means in this context, you'll have to reconfigure the DMA for each cycle of the sine wave.

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