This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

(ULP 2.1) Detected SW delay loop using empty loop. Recommend using a timer module instead

I'm trying to optimise my code in order to extend the battery life. The ULP advisor displays this message " (ULP 2.1) Detected SW delay loop using empty loop. Recommend using a timer module instead" for several lines such as 

   if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF) { while(1);}

and 

if (FCTL3 & ACCVIFG ) { P1OUT |= LED0_Red; while(1); }

How can I use a timer module instead of  while(1); ?

 

Thanks a lot.

Description Resource Path Location<a href="file:/c:/ti/ccsv6/tools/compiler/dmed/HTML/MSP430/1527.html">#1527-D</a>  (ULP 2.1) Detected SW delay loop using empty loop. Recommend using a timer module instead main.c /project5 line 232

  • In this case the timer module does not make sense. while(1); is a trap. The compiler just detects, that you are waisting power by having a software loop for doing nothing over a period of time. To save power, the ULP advisor recommends to use a timer for intervals where nothing has to be done. For example: You want a software delay of 1s, then you can do a for-loop that is executed for 1s doing nothing, but having the processor running at full speed. But you could also start a timer, that generates an interrupt request in 1s, having the CPU running in a low power mode to save energy. The ULP simply detects a software loop, but cannot determine it's task, of course. So it warns you to have a closer look at it. If you decide that this is OK, then everything is fine. A warning isn't a problem simultaneously in every case.

    But be careful - such software loops may be optimized away by the compiler.

    Dennis

  • Hi Dennis,

    Thanks very much for your well explained answer.

    Canberk

**Attention** This is a public forum