Skip to main content
EHabi.1
Associate
Dec 28, 2021 12:53 PM UTC
Question

BUG: CubeMX enables unused channel on dual-channel DAC

I configure STM32F767I(G-I)Tx via CubeMX.

I enabled ADC_IN4 and DAC_OUT2 on dual-channel DAC.

ADC_IN4 shares pin with DAC_OUT1. Even though DAC_OUT1 was not enabled in CubeMX I can see it applies voltage on the pin breaking ADC reading,

This can be solved by adding

sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_DISABLE;
HAL_DAC_ConfigChannel(&hdac, &sConfig, DAC_CHANNEL_1);

to MX_DAC_Init().

Which means CubeMX enables DAC channel which was not configured/enabled in GUI.

IMO, it's better to be fixed at CubeMX level than adding user code which disables unused DAC channel.

This topic has been closed for replies.

3 replies

Sara BEN HADJ YAHYA
ST Technical Moderator
Jan 6, 2022 2:09 PM UTC

Hello @EHabi.1​ ,

Thanks for your feedback,

Which CubeMX version are you using ? and does your code contain the following lines in DAC init when DAC_OUT1 is Disabled in CubeMX GUI ?

 sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE;
 if (HAL_DAC_ConfigChannel(&hdac, &sConfig, DAC_CHANNEL_1) != HAL_OK)
 {
 Error_Handler();
 }

Thanks,

Sara.

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.
EHabi.1
EHabi.1Author
Associate
Jan 9, 2022 6:43 AM UTC

Hi Sara,

I'm on CubeMX 6.3.0 and my DAC init does not contain DAC_OUTPUTBUFFER_ENABLE

for channel 1 (I also checked the whole application code). So it looks like if it's not disabled it will be enabled by default.

Sara BEN HADJ YAHYA
ST Technical Moderator
Jan 13, 2022 1:32 PM UTC

Hello @EHabi.1​ ,

I don't think that this issue is related to CubeMX, there is no lead in the generated code nor in the graphical user interface that points to this issue so I am adding @Imen DAHMEN​  to the loop for review and provide a status update about this issue.

Sara.

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.