cancel
Showing results for 
Search instead for 
Did you mean: 

Hi, I'm trying to write DAC value on Stm32, but I'm unable to do so.

Akshit Singhal
Associate II

When I write the value in loop

eg. VALUE_to_WRITE = 1000;

for(int i =0; i < VALUE_to_WRITE; i++){

   HAL_DAC_SetValue(&hdac, DAC_CHANNEL_1, DAC_ALIGN_12B_L, value);

   HAL_DELAY(4);}//no less than this

The value is written. But it const me 5-10 seconds when I want to write value?

Any help will be appreciated

3 REPLIES 3

What STM32? There are like hundreds of parts over dozens of families, Be Specific!

Defining the board, or describing the circuit would also be helpful.

Not sure why it would delay for 5-10 seconds unless you're got some very odd clocks and timing loops.

Most STM32 DAC will sustain 1 MHz (1 us) update rates, check the Data Sheet.

If driving into a capacitive load consider using a buffer/opamp.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Akshit Singhal
Associate II

I'm using Stm32 - F303CCTx. I'm taking the direct DAC output and feeding it to the multiplier circuit which changes the output voltage range from 0-3.3V to 0-9.9V. I'm already using the opamp. I'm not any delays in this. Even teh basic code which is driving the DAC from 0 - 4095(12 bit right align) needs this delay. I have no idea why.

AvaTar
Lead

[quote]The value is written. But it const me 5-10 seconds when I want to write value?[/quote]

Then you are doing something wrong.

As Clive says, you can update the DAC data register with 1 MHz, but the DAC itself has a settling time of about 2...5ms.

Perhaps you have an hardware issue, and your buffer opamp is inappropriate. Do you have the internal buffer enabled ? Else, the DAC has more than 1 Mega Ohm impedance.