How To Use DAC on STM32F4 Discovery?
There is a problem in the HAL driver for the DAC. If any developer from the AC6 is here, they can correct it in the next version.
In the file stm32f4xx_hal_dac.c, it says, "DAC APB clock must be enabled to get write access to DAC registers using HAL_DAC_Init()". However, the function HAL_DAC_Init() doesn't enable the DAC APB clock. The clock has to be enabled manually by calling the _HAL_RCC_DAC_CLK_ENABLE() macro from the stm32f4xx_hal_rcc_ex.h file.
The image upload plugin isn't working so here are the links to screenshots of the HAL DAC driver.
http://s30.postimg.org/4cgvycz8x/hal_dac.png
http://s30.postimg.org/fnjjmq641/HAL_DAC_Init.png