2024-08-12 04:29 AM
Hi everyone,
I'm encountering an issue with generating a 1 MHz sine wave using the DAC, TIM, and DMA for DDS. I'm utilizing a wave table to generate the sine wave.
Currently, I have the HCLK and APB2 clocks both set to 180 MHz, and I'm using TIM8 as the timer for the DAC. I've configured the timer with a prescaler (PSC) of (1-1) and an auto-reload register (ARR) of (2-1), which gives me an FMCLK of 90 MHz. The LUT (wave table) length is set to 180, and the DAC data width is set to Word. However, instead of the expected 1 MHz output, I'm getting an incorrect result of around 125 kHz.
I've tried various methods and different parameter adjustments. Changing the FMCLK causes the output frequency to drop further, and altering the LUT length affects the output voltage. And under the 130kHz is very normal.
Only using the Digital Storage Oscilloscope to get the wave of board DAC output, and DMA is the High priority in DMA.
There is my code, and I'm referenced other sources.
And this picture is my generated wave, the voltage is down 1v to 2v, and the frequency at 125kHz.
Thanks for help!!
2024-08-12 04:41 AM
The DAC is not able to update at 90 MHz. Reduce the number of samples per period. Looks like it can do about 1/8 of what you want, so maybe shoot for an update rate of 10 MHz.
This app note suggests 10.5 Msps as the max rate. Might be slightly different for your chip.
It's going to be tough to get a clean 1 MHz without artifacts.