cancel
Showing results for 
Search instead for 
Did you mean: 

May I know what is the 100000, 2 and 10 in the calculation of start-up time for ADC voltage regulator that I got with Auto-generated LL_driver code.

Umahe.1
Associate II

I'm trying to configure ADC for stm32 NUCLEO-U575-ZI-Q and while generating the code using LL drivers noticed the start-up time for ADC voltage regulator and need to know what actually is 100000, 2 and 10 . Same screenshot is attached with it. Thanks in advance.

4 REPLIES 4

It's a sloppy delay loop, it doesn't use volatile either, so apt to be removed by the optimizer completely.

Perhaps just delay in micro-seconds what the constant defines as being needed.

Perhaps use a free-running TIM at 1 or 10 MHz...

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Mike_ST
ST Employee

Hello,

Entered a ticket for the missing "volatile"...

ticket 133282.

Umahe.1
Associate II

Sorry @Community member​ and @Mike_ST​ , I didn't your response. Did you mean that the while loop and calculation that I'm using is not related to ADC Voltage Regulator?

If not what and how to know the start-up time that Voltage Regulator requires?

      uint32_t wait_loop_index;                                                          
      wait_loop_index = ((LL_ADC_DELAY_INTERNAL_REGUL_STAB_US *     
                (ADC_SYSTEM_CORE_CLOCK / (100000 * 2))) / 10);                                                  
      while(wait_loop_index != 0)                                                        
      {                                                                                  
         wait_loop_index--;                                                             
      }   

The LL_ADC_DELAY_INTERNAL_REGUL_STAB_US contains the stabilization delay in micro-seconds, likely from something like the Data Sheet or Reference Manual, if you think the define is wrong, and want to understand the source.

The more normative solution to sub-ms delays would be to free-run a maximal timer, at 1 or 10 MHz (depending on the level of granularity you want to resolve time). Maximal meaning running the full 16 ot 32-bit period of the TIMx peripheral, with a prescaler to hit the count frequency, such that you can read the CNT (count) value and delta the advancement of that count vs the time you needed to minimally wait.

Simplistically

start = TIM2->CNT;

while((TIM2->CNT - start) < 100) {} // in a 10us from 10 MHz sense

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..