EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Delay loop & IAR

Started by Frederic Beaulieu November 30, 2004
Hi all,
Is there someone who have a predictable delay loop
function which is not optimized (remove) by the IAR
(or all) compiler. MSPGCC have the following function
but it don't compile on IAR.

/******************************************************/
// Name        : Wait
// Description : Compact and predictable delay loop
/******************************************************/
Void_t __inline__ Wait(register Word2_t n){
  __asm__ __volatile__(
		       "1: \n"
		       " dec %[n] \n"
		       "jne 1b \n"
		       : [n] "+r"(n));
}
/******************************************************/

Thanks in advance!
Fred


		
__________________________________ 
 

Beginning Microcontrollers with the MSP430

Hi,

i'm using this function:

// busy waiting
void
wait_ms (const unsigned int ui_steps_ms)
{
  volatile unsigned long int uli_down_counter = 482;    // At 8 MHz: measured
with oscilloscope and ui_step_ms=1, 100, 10000.
                                                                               
// With  4,8 MHz DCO: must be 290.
  uli_down_counter *= ui_steps_ms;
  while (uli_down_counter--)    // busy waiting
  {
  };
  return;
}

i think it varies with the compiler and the options.
For less than 1 ms you should use a macro and a global down_counter.

Rolf



msp430@msp4... schrieb am 30.11.04 17:52:49:
> 
> 
> Hi all,
> Is there someone who have a predictable delay loop
> function which is not optimized (remove) by the IAR
> (or all) compiler. MSPGCC have the following function
> but it don't compile on IAR.
> 
> /******************************************************/
> // Name        : Wait
> // Description : Compact and predictable delay loop
> /******************************************************/
> Void_t __inline__ Wait(register Word2_t n){
>   __asm__ __volatile__(
> 		       "1: \n"
> 		       " dec %[n] \n"
> 		       "jne 1b \n"
> 		       : [n] "+r"(n));
> }
> /******************************************************/
> 
> Thanks in advance!
> Fred
> 
> 
> 		
> __________________________________ 
>  
> 
> 
> 
> .
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 
> 





The 2024 Embedded Online Conference