2025-05-23 12:16 PM
I'm using STM32CubeMX 6.14.1
Recently I was added DAC to my project. I doesn't suppose to use DAC with interrupt, I wasn't enable it, but occasionally I was enabled DAC callbacks.
Generated the code for Makefile based project.
In the end of building process, linker thrown errors:
/usr/lib/gcc/arm-none-eabi/12.2.1/../../../arm-none-eabi/bin/ld: build/stm32f0xx_hal_dac.o: in function `HAL_DAC_Init':
/home/tovis/nusi/worke/STM32/F051_ccl/Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_dac.c:304: undefined reference to `HAL_DACEx_ConvCpltCallbackCh2'
/usr/lib/gcc/arm-none-eabi/12.2.1/../../../arm-none-eabi/bin/ld: /home/tovis/nusi/worke/STM32/F051_ccl/Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_dac.c:304: undefined reference to `HAL_DACEx_ConvHalfCpltCallbackCh2'
/usr/lib/gcc/arm-none-eabi/12.2.1/../../../arm-none-eabi/bin/ld: /home/tovis/nusi/worke/STM32/F051_ccl/Drivers/STM32F0xx_HAL_Driver/Src/stm32f0xx_hal_dac.c:304: undefined reference to `HAL_DACEx_ErrorCallbackCh2'
I made some investigation, and turns out, that in generated code stm32f0xx_hal_dac.c DAC handled as it have two channel - STN32F051 have only one channel DAC. From the other side, where the callbacks are defined there is a series #ifdef and list of STM32F0xx MCUs which have two channel DAC (stm32f0xx_hal_dac_ex.c row: 1088). With this setup callbacks for the second channel aren't generated, what leads to linker error.
When I understand what's the problem, I simply disabled callbacks. My problem is solved, but I think it's a bug and sometime shall be corrected.
2025-05-23 12:56 PM
Hello @tovis
could you please upload your .ioc file.
Best Regards.
STTwo-32
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-05-23 10:35 PM
2025-05-28 2:48 AM
2025-05-28 5:01 AM
Hello @tovis ,
First let me thank you for bringing this issue to our attention.
An internal ticket is submitted to the dedicated team (Ticket Number: 211008)
Thanks.
Mahmoud
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-05-28 5:44 AM
Thank you and your dedicated team.
Other question, in such a situation what is the best solution?
Before I realize that i don't need callbacks, I was trying to make code useful, simply add my MCU to list where those callbacks are take a place (#ifdef) - code become linkable. But solution is dirty, left some inappropriate code in the result elf and bin.
The next approach, would be exclude inappropriate fields even from handle structure and initialization. More tedious and dangerous. Also, if I change the configuration and generate code I would correct the code again, may be use patch.
Is there a better approach?