Skip to main content
Senior
February 7, 2025
Solved

STM32H563 DAC1

  • February 7, 2025
  • 4 replies
  • 2233 views

I used CubeMX 6.12 to generate code and DAC output works as intended.

I cloned that project, migrated to CubeMX 6.13 and generated code. DAC output doesn't work. Migration to 6.13 also used FW H5 1.4 instead of 1.3.

Comparing stm32h5xx_hal_msp.c I see the 6.13 generated code lacks

RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
if(hdac->Instance==DAC1)
{
 /* USER CODE BEGIN DAC1_MspInit 0 */

 /* USER CODE END DAC1_MspInit 0 */

 /** Initializes the peripherals clock
 */
 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_DAC;
 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
 {
 Error_Handler();
 }
}

in HAL_DAC_MspInit(). When I add the above code to stm32h5xx_hal_msp.c in the migrated project, DAC output works as expected.

No significant differences between the IOC files.

Is there a problem with CubeMX 6.13?

Attaching STM32H563VIT6_2.ioc (original, CubeMX 6.12, DAC works) and NGC_HW_Verification_Clone.ioc (cloned, CubeMX 6.13, DAC doesn't work).

Best answer by Mahmoud Ben Romdhane

Hello @mccabehm @AScha.3 ,

 

Thank you for reporting this issue.

I am escalating an internal ticket to the concerned Team (ticket number: 202681).

 

Best Regards.

Mahmoud

4 replies

AScha.3
Super User
February 7, 2025

What its doing, if you select using FW H5 1.3 again ?

"If you feel a post has answered your question, please click ""Accept as Solution""."
mccabehmAuthor
Senior
February 7, 2025

I do not know how to revert a project to an earlier CubeMX and FW version. Using STM32CubeIDE v1.17

AScha.3
Super User
February 7, 2025

go : menu -> help -> configuration tool -> manage embedded...

then:

AScha3_0-1738954668597.png

select (green button) to delete...and select other version -> green = active is the most recent/newest.

So deselect 1.4  on H5.

btw

You see, i still use 1.11.2 H7 - why should i update, if everything i use is working fine ?

Just to find new errors...?

"If you feel a post has answered your question, please click ""Accept as Solution""."
mccabehmAuthor
Senior
February 7, 2025

I had to update to get correct VREFBUF handling for H563.

Deselecting H5 1.4 won't affect existing project. From what I've seen, this is only used when a project is created. The only H5 1.4 options are Refresh and Remove...

mccabehm_0-1738957252611.png

 

AScha.3
Super User
February 7, 2025

So you need to use v 1.4 ? (as i understand it...)

>From what I've seen, this is only used when a project is created.

try: open Mx view, then generate code . -> compile and check it...

 

"If you feel a post has answered your question, please click ""Accept as Solution""."
Technical Moderator
February 10, 2025

Hello @mccabehm ,

First let me thank you for posting.

Your request is under investigation, and I will get back to you ASAP.

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.
mccabehmAuthor
Senior
February 13, 2025

CubeMX 6.13 DAC1 configuration...

mccabehm_4-1739462113340.png

 

CubeMX 6.12 configuration...

mccabehm_5-1739462164100.png

mccabehmAuthor
Senior
February 13, 2025

Good DAC output...

scope_0.png

 

Bad DAC output...

scope_1.png

Amplitude is ~6v because of an op-amp downstream of the DAC1 channel 1 MCU pin. Scope trace taken at the MCU pin looks the same, except amplitude is ~2.5v.

I am unwilling to supply more information related to this issue. CubeMX 6.12 generates this required initialization code for the DAC

 RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};

 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_DAC;
 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
 {
 Error_Handler();
 }

CubeMX 6.13 does not. The DAC will not work without a clock. If this is not sufficient to identify the problem, I am sorry. I am using the DAC untriggered, probably not normal. My requirement for DAC frequency is very low (< 20 Hz) so I don't need SW or HW triggering yet. This issue is also documented in https://community.st.com/t5/stm32-mcus-products/stm32h563vit6-dac1-output-unexpected/td-p/769306 and presents similar info.

 

Technical Moderator
February 25, 2025

Hello @mccabehm ,

 

After investigation, adding this code will lead to the issue: 

RCC_CCIPR5-> ADCDACSEL[2:0]" is unintentionally overwritten.

When ADC is enabled and DAC1 is configured in Normal mode, they are sharing the same clock mux and, in this case, generating PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_DAC; in HAL_DAC_MspInit()

is overriding RCC_CCIPR5->ADCDACSEL[2:0].

For that, PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_DAC; was removed from the generated code.

 

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.