Aaron Littich

Simple problem with if-then statements, where am I going wrong?

Discussion created by Aaron Littich on Jan 17, 2008
Latest reply on Jan 17, 2008 by Aaron Littich
I am very confused why the code is doing the following in a simple if-then structure:

interrupt 12 void MTIM_ISR(void){

    MTIMSC_TOF = 0;
 
    if(i== 0)
    {
      PTBD_PTBD4 = 0;
      PTBD_PTBD5 = 1;
      PTBD_PTBD6 = 1;      // JUMPING FROM HERE
      i++;
    }
    else if(i==1)
    {
      PTBD_PTBD4 = 1;
      PTBD_PTBD5 = 0; 
      PTBD_PTBD5 = 1;
      i++;                             // TO HERE, AND THEN OUT
    }
    else
    {
      PTBD_PTBD4 = 1;
      PTBD_PTBD5 = 1;
      PTBD_PTBD6 = 0;
      i= 0;
    }
    
   
}

This is just a interrupt handler for a timer-based delay.  Is the compiler optimizing the code in some weird way?  This basically blinks three led's in order based on the i index, and then starts back over at the first led (i=0).

Thanks,
Aaron

Outcomes