I would appreciate any help getting past this problem. I am attempting to write code that I can use to update the program in flash memory. I am using the xc16x_iap-flash example and so far have successfully managed to locate the flash programming section to RAM and am able to erase and write to flash memory from it. The next part has me confused though. When I erase the sector 0xC00000 (beginning of flash memory) the program in RAM stops running. It appears as though constants from my program in RAM are being stored in flash. I assume that I am missing something in the L166 Locate Options, but after trying many combinations I am quite lost on how to set this up correctly. Keil xc16x_iap-flash example: http://www.keil.com/download/docs/xc16x_iap-flash.zip.asp
This is an In-Application Program Update. What I want to do is have the application load new code from a serial port and store it in RAM. Then, I want the application to jump to a loader function that copies the new code from RAM to Internal Flash. At this point the device is reset with the new program. Where I am stuck is making the entire loader function reside in RAM so erasing/writing the Flash does not effect it.