It looks that the source originates from an example I wrote for a STM32World Tutorial video. IF you have not watched the video, I'd recommend that as it goes through the setup in STM32CubeMX. I don't see anything obviously wrong in your code, so most likely it is in the CubeMX setup.
https://www.youtube.com/watch?v=0N4ECamZw2k
The working example for STM32F405 is here: https://github.com/STM32World/stm32fun/tree/master/stm32world_dac1