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.
thanks,
yashar
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.
thanks,
yashar
You might have a look at this paper, which describes a direct digital synthesis approach to audio tone generation up to 40 kHz. http://www.g4jnt.com/PIC_DDS.pdf
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.
You might have a look at this paper, which describes a direct digital synthesis approach to audio tone generation up to 40 kHz. [[http://www.g4jnt.com/PIC_DDS.pdf]]
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.
@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.
@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.
Important Information for this Arm website
This site uses cookies to store information on your computer.
By continuing to use our site, you consent to our cookies.
If you are not happy with the use of these cookies, please review our
Cookie Policy
to learn how they can be disabled.
By disabling cookies, some features of the site will not work.
Access Warning
You do not have the correct permissions to perform this operation.
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.
thanks,
yashar