You have a lot of stuff connected to your PIC !
I just checked the code real quickly and I have something to propose.
Like kersing said, dual-boot implies you "reboot" the controller. From there you have two options IMO:
1) Have a variable in the EEPROM with which you can start one of the three programs.
2) Have a sort of a bootloader to chose one of the three programs.
The first one, I don't know how you would change the value in eeprom.
But the second one could be interesting.
You could have your microcontroller use your PC monitor to display which program you want to boot.
Have your microcontroller connect to your PC with USART or USB Serial (if it has it) and use a program like Hyperterminal or PuTTy to connect to the microcontrollers COM port and display text sent from your microcontroller.
Your PC could then display a message like :
PIC 18F252 Bootloader v0.0:
(Press corresponding number to boot a program)
1) Program 1
2) Program 2
3) Program 3
... Waiting user input ...
Once the user has chosen which program to boot, you can re-initialize the microcontroller by resetting the I/O pins to whatever it is you want (as long as it doesn't conflict with the USART/USB hardware).
Your bootloader is nothing more than a simple state machine, check the pseudo code:
Code: Select all
// main
IO_Init(); // initialise IO for USB
USBSerial_Init(); // initialise USB Serial
USBSerial_SendString("PIC 18F252 Bootloader v0.0:\n(Press corresponding number to boot a program)\n ...etc"); // send string throug USB Serial
// main loop
while (1)
{
user_response = USB_waitForUserInput(); // loop in function while no char received
switch(user_response)
{
case '1': // if user pressed 1
bootProgram1(); // call program 1
break;
case '2': // if user pressed 2
bootProgram2(); // call program 2
break;
case '3': // if user pressed 3
bootProgram3(); // call program 3
break;
default: // if user sent anything else than 1, 2 or 3
// error, received char not recognized
}
}
The only way to choose a new boot is to reboot the microcontroller so the user can choose what program to run.
I think that's close enough to what a PC does

.