2023-10-30 01:14 PM - edited 2023-10-30 01:16 PM
I am using stm32f407g.
I wrote this simple code which (in theory) should give on pin PA4 the voltage set in "DACout_v" (in this case I set 2.8V)
Following this document (the section "Digital sine waveform pattern preparation") I derived DOR and then gave it to "HAL_DAC_SetValue".
With te oscilloscope I measure 2.60V. Why? I would like to understand what I am doing wrong.
float DACout_v = 2.8; //outside the main
while (1) {
DACout_d = DACout_v*(0xfff)/3.3; //DOR
HAL_DAC_SetValue(&hdac, DAC_CHANNEL_1, DAC_ALIGN_12B_R, DACout_d);
}
Thank you.
Solved! Go to Solution.
2023-10-30 02:53 PM
VDD/VDDA/VREF+ is 3.0V on that board. That explains the issue.
2023-10-30 02:20 PM
So ~10% error. Is your VREF+ 3.3V? What hardware is this?
2023-10-30 02:42 PM - edited 2023-10-30 02:44 PM
I had not "calculated" the percentage error, in fact 10% error makes me think I was wrong in using 3.3V ... maybe I should put 3V. I do not have the microcontroller I am using (stm32f407g-disc1) with me at hand, but I am afraid of that Vref is 3V and not 3.3V
I'll check as soon as I can.
2023-10-30 02:53 PM
VDD/VDDA/VREF+ is 3.0V on that board. That explains the issue.