Hi,

[email protected] schrieb am 29.11.02 15:44:10:
> How about declaring 'i' as volatile??
> 
> volatile int i;
> for (i=0; i<N; i++)
>  continue;
> 
> Haven't tried this but just maybe...

Yes, you can also find it in the hello world program (for the FET hello world 
LED; http://www.mikrocontroller.net/mspgcc.htm):

#include <io.h>

void wait(void);         //prototype for wait()

int main(void)
{
  P1DIR=0xFF;            //port 1 = output
  P1OUT=0x01;            //set bit 0 in port 1
  
  for(;;) {              //infinite loop
    P1OUT=~P1OUT;        //invert port 1
    wait();              //call delay function
  }
  
}

void wait(void)          //delay function
{
  volatile int i;        //declare i as volatile int
  for(i=0;i<32000;i++);  //repeat 32000 times
}


I've tried it and it works.

Best regards 

Rolf Freitag




Reply via email to