cancel
Showing results for 
Search instead for 
Did you mean: 

Method to control the full scale output of the DAC (volume control) ?

LorAlex
Associate

Hello,

I use the DAC together with the DMA in circular mode to generate a sinewave of a few Hz. A buffer is filled with the predefined values of one sine period. The frequency is adjusted with the DAC clock and the sine amplitude by updating the sine buffer. Currently I am using the "half/full buffer transmitted" flags of the DMA to multiply the sine table by a gain value by SW. It works well, however I wonder if there is a simpler way to control this "volume" to modify the amplitude of the sinewave.

I would like to avoid cascading external DAC and rather take benefit of the STM32 peripherals and the high performance of the H7, and to limit cost too.

My problem with the current method is that I can only refresh the gain once per period and the application would probably take benefit of a better dynamic.

Using the OPAMP with the PGA coule be a solution but it must be "linear controlled".

An HW solution like VCA or by using a second external DAC are for the moment my alternatives.

Let me know if you know a better solution.

Thanks

2 REPLIES 2
TDK
Guru

There's no multiplier adjustment value if that's what you're looking for.

You don't need to wait for the next HT/TC event. You can populate the array at any point and the DMA will send the updated data the next time it sends data. Populate in reverse order beginning at the current location will ensure only a single transition point between data sets.

There are certainly op-amp based hardware solutions as well.

If you feel a post has answered your question, please click "Accept as Solution".
MasterT
Senior III

Making DMA buffers smaller is an option to increase responsiveness. H7 fast enough to refill an array-32 in less than usec, especially if sine precalculated and stored in Flash, and only multiplication by scaling factor is required. My guess, DAC is running below 1 MSPS, since external OPA is not used ( up to 10 MSPS possible). Problem with low resolution DAC (12 bits) and magnitude adjustment - degrading resolution even more , since at -20dB more than 3 bits lost, and accounting for AC , less than 8 bits left. But paralleling 2 DAC to get 16-20 bits may be an option. Otherwise, there is Volume control IC with digital interface.