AnsweredAssumed Answered

STM32F4 oddities in stm32f4xx_hal_adc.c

Question asked by childress.steve on Jan 23, 2015
Latest reply on Feb 26, 2015 by Montassar BEN ROMDHANE
In the STM32F4xx HAL, file stm32f4xx_hal_adc.c
there is this code

/* Check if ADC peripheral is disabled in order to enable it and wait during
   Tstab time the ADC's stabilization */
if((hadc->Instance->CR2 & ADC_CR2_ADON) != ADC_CR2_ADON)
  /* Enable the Peripheral */
  __HAL_ADC_ENABLE(hadc);
   
  /* Delay inserted to wait during Tstab time the ADC's stabilazation */
  for(; i <= 540; i++)
  {
    __NOP();
  }
}

1. The for loop seems to be missing "i = 0" but the local variable is declared and 0'd at the top of the function. The for loop thus assumes no prior use of i.
2. The time delay is done with a no-no CPU-speed dependent constant.

I wonder if this runs only when the ADC is initialized at startup. So it won't hurt too much if it's wrong.


This seem

Outcomes