This program seems to jump between cases without any reason.
Code:
INDEX = 1;
While(1) {
switch (INDEX){
case 1: //INDEX = 1
if (ABC < LOOKUP3(TPS_INDEX, OneUP, 10)){
INDEX = 1;
HIGH(29);
LOW1(20);
LOW1(23);
LOW1(25);
} //END IF
else {
INDEX = 2;
HIGH(29);
HIGH1(20);
LOW1(23);
LOW1(25);
} //END ELSE
break; //END GEAR INDEX = 1
case 2: //INDEX = 2
if (ABC >= LOOKUP3(TPS_INDEX, TwoUP, 10)){
INDEX = 3;
LOW(29);
HIGH1(20);
LOW1(23);
LOW1(25);
} //END IF
else {
if (ABC < LOOKUP3(TPS_INDEX, TwoDOWN, 10)){
INDEX = 1;
HIGH(29);
LOW1(20);
LOW1(23);
LOW1(25);
} //END IF
} //END ELSE
break; //END INDEX = 2
case 3: //INDEX = 3
if (ABC >= LOOKUP3(TPS_INDEX, ThreeUP, 10)){
LOW(29); //SS1
LOW1(20); //SS2
LOW1(23); //CCS
LOW1(25); //TCS
} //END IF
else {
if (ABC < LOOKUP3(TPS_INDEX, ThreeDOWN, 10)){
INDEX = 2;
HIGH(29);
HIGH1(20);
LOW1(23);
LOW1(25);
} //END IF
} //END ELSE
break; //END INDEX = 3
case 4: //INDEX = 4
if (RPM < LOOKUP3(TPS_INDEX, FourDOWN, 10)){
INDEX = 3;
LOW(29);
HIGH1(20);
LOW1(23);
LOW1(25);
} //END IF
else {if (ABC >= 850){
HIGH1(25);
} //END ELSE
else {if (ABC < 700){
LOW1(25);
}}} //END If End ELSE End Else
// END INDEX = 4:
} //End Switch INDEX
WAIT(100);
} //End While
Do you need the last break at the end of the case statements?
Does the program jump to the end of the program and then follow the while loop when a break is encountered, or to the end of the case statements?
Do I need a Default Statement?