What you are trying to do is create a program code 'overlay'.
Whilst this happens all the time in a conventional CPU arrangement like your PC, the internal archetecture of the PIC causes some limitations.
1. You need to load the PIC codespace reserved for the overlay in real-time from an external device (such as an EEPROM). This is possible, but not practical from a real-time point of view... certainly not for a single subroutine. It takes significant time to load an overlay... eg you want to display your '8' and it might take 500mS... fine... you can cope with that, but filling a 2 x 16 LCD witch characters that way could take 15 seconds! when I played with this a couple of years back, I recall I was getting a loading delay of about 15 seconds per 1000 words of codespace at best.
2. There is a limit to the number of codespace write/rewrite operations before you wear out the PIC. 100,000 operations may seem a lot, but if you're going to do it once every second to the same spot... your PIC will die before the end of the week.
You can use this method to load say a complex Set-Up/Menu program which is only likely to be used rarely... and then once exited to reload your main program. There is still however a significant time-lag which is unacceptible.
The answer is therefore, Yes, it can be done, but because of the PIC's archetecture it's impractical, delivers unacceptibley poor loading times that cripple overall program performance, and has a limited life cycle.
If you need more codespace, go to an 18 series with 32kb.
Bookmarks