Skip to main content
OGhis
Senior
September 1, 2019
Question

BUG: STM32G474RE Assert issue for DAC1 initialization.

  • September 1, 2019
  • 0 replies
  • 703 views

With the CubeMX 5.3.0 with the STM32G474RE V1.1.0 library is the assert_failed called when MX_DAC1_Init() is executed.

The DAC1 was configured as follow:

0690X00000AQLXrQAP.png

The assert was called from the "MX_DAC1_Init()" function

 sConfig.DAC_HighFrequency = DAC_HIGH_FREQUENCY_INTERFACE_MODE_AUTOMATIC;
 sConfig.DAC_DMADoubleDataMode = DISABLE;
 sConfig.DAC_SignedFormat = DISABLE;
 sConfig.DAC_SampleAndHold = DAC_SAMPLEANDHOLD_DISABLE;
 sConfig.DAC_Trigger = DAC_TRIGGER_NONE;
 sConfig.DAC_Trigger2 = DAC_TRIGGER_NONE;
 sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_DISABLE;
 sConfig.DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_ENABLE; // <<====
 sConfig.DAC_UserTrimming = DAC_TRIMMING_FACTORY;
 if (HAL_DAC_ConfigChannel(&hdac1, &sConfig, DAC_CHANNEL_1) != HAL_OK)

The  sConfig.DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_ENABLE is the cause called by

assert_param(IS_DAC_CHIP_CONNECTION(sConfig->DAC_ConnectOnChipPeripheral));

The value for DAC_CHIPCONNECT_ENABLE is 6 but the macro "IS_DAC_CHIP_CONNECTION" tell is:

#define IS_DAC_CHIP_CONNECTION(CONNECT) (((CONNECT) == DAC_CHIPCONNECT_EXTERNAL) || \
 ((CONNECT) == DAC_CHIPCONNECT_INTERNAL) || \
 ((CONNECT) == DAC_CHIPCONNECT_BOTH))
#if defined(STM32G4)
#define DAC_CHIPCONNECT_DISABLE (DAC_CHIPCONNECT_EXTERNAL | DAC_CHIPCONNECT_BOTH)
#define DAC_CHIPCONNECT_ENABLE (DAC_CHIPCONNECT_INTERNAL | DAC_CHIPCONNECT_BOTH)
#endif

So the "IS_DAC_CHIP_CONNECTION" has an incorrect definition, because it checks only for:

  • DAC_CHIPCONNECT_EXTERNAL
  • DAC_CHIPCONNECT_INTERNAL
  • DAC_CHIPCONNECT_BOTH

and for the DAC_CHIPCONNECT_ENABLE  the macro must checks also the the combination of:

DAC_CHIPCONNECT_ENABLE (DAC_CHIPCONNECT_INTERNAL | DAC_CHIPCONNECT_BOTH)
 

This topic has been closed for replies.