2024-07-08 07:12 AM - last edited on 2024-07-08 07:41 AM by SofLit
Used STM32CubeIDE version: 1.15.1
Used driver library: STM32Cube_FW_G0_V1.6.2, LowLevel-Drivers
Microcontroller STM32G070xx
I found a bug in the generated MX_ADC1_Init() function. The delay loop index variable misses the volatile keyword. Consequently with optimization turned on the loop is optimized away and the delay is shorter than expected. This may lead to unexpected ADC errors, for example if the calibration is performed directly after MX_ADC1_Init().
void MX_ADC1_Init(void)
{
...
/* Enable ADC internal voltage regulator */
LL_ADC_EnableInternalRegulator(ADC1);
/* Delay for ADC internal voltage regulator stabilization. */
/* Compute number of CPU cycles to wait for, from delay in us. */
/* Note: Variable divided by 2 to compensate partially */
/* CPU processing cycles (depends on compilation optimization). */
/* Note: If system core clock frequency is below 200kHz, wait time */
/* is only a few CPU processing cycles. */
volatile uint32_t wait_loop_index; // <-- volatile at the beginning of this line is missing in the generated code
wait_loop_index = ((LL_ADC_DELAY_INTERNAL_REGUL_STAB_US * (SystemCoreClock / (100000 * 2))) / 10);
while(wait_loop_index != 0)
{
wait_loop_index--;
}
...
}
As far as I can see in the release notes of the new STM32CubeIDE v1.16.0 this problem has not been fixed yet.
Solved! Go to Solution.
2024-11-27 02:44 AM
Hello,
Issue is fixed on CubeMx V6.13.0
2024-07-08 07:43 AM - edited 2024-07-08 07:53 AM
Hello @SOfne.1 ,
I'm escalating your feedback internally. I will get back to you as soon as I have an internal feedback.
Internal Ticket: 186041
2024-11-27 02:44 AM
Hello,
Issue is fixed on CubeMx V6.13.0