I’m afraid I don’t use Easy C, so I can’t help you there. I always program by starting with the Default User Code and inserting my own logic.
I couldn’t find the source code I mentioned earlier in the thread so I wrote up a new example. I have not tested this, but it is very similar to what I used before and should work OK. If I get a chance this evening, I’ll try running it to see if it really works 
Start with the Default User Code, and edit “user_routines.c”. First, you need to declare a few variables:
/*** DEFINE USER VARIABLES AND INITIALIZE THEM HERE ***/
int Switch_Debounce = 0; /* used to clean up switch signal */
unsigned int Switch_State = OPEN; /* Debounced Switch State */
unsigned int Prev_Switch_State = OPEN; /* Switch state remembered from the previous pass */
unsigned int Release_Timeout = 0; /* Counts sixty 17ms cycles to end user input */
unsigned int Press_Count = 0; /* Current press count, or 0 if none */
unsigned int Running_Program = 0; /* Which program is running, or 0 if none */
Then, you need to make sure and define your switch as an INPUT:
void User_Initialization (void){
...
/* Add any other user initialization code here. */
IO1 = INPUT; /* Use switch on IO1 to select program to run */
...
}
Third, you need to insert the state machine code into the main program loop:
void Process_Data_From_Master_uP(void)
{
...
/* Add your own code here. */
/* First, debounce the switch signal to avoid false counts */
if (rc_dig_in01 == CLOSED) {
if (Switch_Debounce++ >= 2) {
Switch_State = CLOSED;
Switch_Debounce = 2;
}
} else {
if (Switch_Debounce-- <= -2) {
Switch_State = OPEN;
Switch_Debounce = -2;
}
}
/* Second, read the switch and run the state machine */
if (Switch_State == CLOSED) { /* Switch is pressed, */
if (Prev_Switch_State == OPEN) /* but was not last time. */
Press_Count++;
} else { /* Switch is not pressed, */
if (Prev_Switch_State == CLOSED) { /* but was pressed last time, */
Release_Timeout = 60; /* so start the 1s timeout. */
} else if (Release_Timeout) {
Release_Timeout--;
if (Release_Timeout == 0) { /* 1 sec since last release, */
Running_Program = Press_Count; /* so run selected program. */
Press_Count = 0;
switch (Running_Program) {
case 1: Program1_Init(); break; /* Init Prog 1 */
case 2: Program2_Init(); break; /* Init Prog 2 */
case 3: Program3_Init(); break; /* Init Prog 3 */
case 4: Program4_Init(); break; /* Init Prog 4 */
default: Running_Program = 0; /* Unknown program */
}
}
}
}
Prev_Switch_State = Switch_State; /* Remember switch state. */
/* Finally, call out to whichever program is active */
switch (Running_Program) {
case 1: Program1(); break; /* Run Program 1 */
case 2: Program2(); break; /* Run Program 2 */
case 3: Program3(); break; /* Run Program 3 */
case 4: Program4(); break; /* Run Program 4 */
default: Running_Program = 0; /* Unknown program */
}
...
}
And finally, you need to define functions for Program1_Init(), Program1(), etc. The Program#_Init() functions will be called once when a program is selected, and the Program#() functions will be called every 17ms after that.
You can select a new program at any time by simply pressing the right number of times. It will stop the current program and switch to the new one 1s after the last press.
I know this isn’t Easy C, but I hope you find it helpful nonetheless.