2021-05-09 05:40 AM
Hello. I have written a program to run the DAC in the STM32F107VC and I have used STM32CubeMX and HAL functions. But I don't see any waveform in the DAC output (PA4 pin). I was able to run the DAC using set the DAC registers. But I don't succeed with HAL functions. I use this functions:
MX_DAC_Init(); // generated with STM32cubeMX
HAL_DAC_Start(&hdac, DAC_CHANNEL_1);
HAL_DAC_SetValue(&hdac, DAC_CHANNEL_1, DAC_ALIGN_12B_R, 1800);
With 1800 value, I should have a voltage of 1.4v at the output. Also, the DAC settings in STM32CubeMX are as follows:
Output buffer: Enable
Trigger: None
According to the training provided in this link.
Thank you for your guidance.
2021-05-11 10:17 AM
Hello RezaMRBM,
are you using some custom board or ST eval board for STM32F107 STM3210C-EVAL? Both cases I would recommend to take look on example for this MCU called DAC_SignalsGeneration available in STM32CubeF1 software package.
You have said you were able to run the DAC using set the DAC registers. Please check registers when they are working as you intended and compare them with the state after HAL_DAC_Start() function. You can send the state of DAC registers also here.
Let me know if you were able to solve the problem.
2021-10-21 02:13 PM
Hello Mr. Petr DAVID,
Sorry for my delay. I use self-designed custom board and will work on this issue again and I will send the result for you.
Best regards
2021-10-21 09:05 PM
Sanity check: use debugger and stop the code after started running to see gpio and dac hw registers.
Pin must be analog mode (gpio.moder), clock enabled (registers can be manually read/write). Same for dac. Manually adjust the registers until your output works. Make sure the analog has supply voltage, vdda or vdd.
2021-10-22 11:48 PM
Thank you for your guidance. I will definitely do that.