embeddedstm32dacstm32cubemxcubemx

Outputting a Triangular Waveform from a DAC Output Pin at a rate of 77khz on an stm board


I am currently working on an stmG474-re development board and aiming to use dac1 channel 2 to output a triangular waveform at a frequency of 77khz with the high resolution timer but struggling to reach the higher frequency of 77khz required.

Generating a triangular waveform is not an issue I have done this through multiple methods now via:

However with each of these method I cannot seem to reach the high frequency required. Using the triangular waveform I am constrained to a period of 72 us. This is something I observe on my oscilloscope. Going above a frequency of approx 500kHz with the DMA creates a bottleneck and the DAC can't update fast enough instead outputtting a constant value.

I'm no expert in using cubeMX and pretty new to embedded programming but if anybody could suggest methods for outputting a triangular waveform at this frequency that would be great. Other Points:


Solution

  • Use TIM6 instead which is "dedicated" for DAC.

    if TIM clock is 170MHz

    You will need 10 samples per period.