cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H563 DAC1

mccabehm
Senior

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).

10 REPLIES 10

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.