Sine Wave generator

28 Apr 2011

Hi guys, im new to mbed and i had couple of questions. im trying to build a sinewave generator with 4 variable frequency (38khz,39khz,40khz,and 41khz) using sine data tables. i have already measured the time that takes to write to AnalogOut and it is around 2us. so for data table with 32 elements for example i can only generate up to 15.3khz including the delay for for loop. data table with 16 obviously gives me twice of frequency 30.6khz and it desnt have a good resolution and for 8 element data table i would have a desired frequencies with bad resolutions. i was thinking to use DAC in combination of Timers and DMA. please guide me to setup a DAC with DMA and timers to generate sine waves with desired frequencies.



28 Apr 2011

You might have a look at this paper, which describes a direct digital synthesis approach to audio tone generation up to 40 kHz.

He uses a 100KHz interrupt. The interrupt service routine increments a counter that tracks the "phase" of the signal. The frequency is determined by the size of the increment. The counter output feeds a sine lookup table and then a DAC.

12 May 2011

This may be the droid er... the code you´re looking for There's an example for generating a sine wave.

01 Sep 2018

@Jacques Pelletier Thanks, I wanted a quick and simple sine wave generator so Googled a solution and turned up your post with a link to one I made 7 years ago and forgot about. Lifes funny.

You need to log in to post a reply