2014-03-28 08:42 AM
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. #stm32f42014-03-28 08:51 AM
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.2014-03-28 08:55 AM
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.2014-03-28 01:30 PM
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.
2014-03-28 01:37 PM
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.2014-03-28 03:30 PM
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.
2014-03-28 03:34 PM
I don't understand what ''sweep'' means in this context, you'll have to reconfigure the DMA for each cycle of the sine wave.