I'm in the process of writing an I2C bootloader for a PIC18F2520 in assembly which is set to reside in the last part of program memory. The bootloader is accessed with a GOTO "bootloader label" statement which occupies the first two program memory locations.
The application code arrives via I2C in packets of 32 bytes (16 opcodes split in two) and is written to a buffer in RAM. I've determined that I need to move the GOTO INIT opcodes for the application code out of the RAM slots that would put the opcodes in the first two flash memory locations and move them into the slots for the third and fourth locations before I write the first packet to flash in order to maintain access to the bootloader on power-up or reset. I'm using DEFINE LOADER_USED 1 to keep the first 4 memory locations in the application code reserved for GOTOs so I don't overwrite any code when I move the opcodes in the bootloader.
I've noticed that every time I include either an I2CWRITE or I2CREAD statement in the application code, a 0x6A00 (clrf 0) opcode shows up in the first program memory location, bumping the normal GOTO INIT down to the second and third memory locations. When the bootloader tries to move the GOTO INIT opcodes up, it won't get both of the GOTO opcodes that are needed to access the application later.
How can I keep the I2C statements from inserting that opcode at the beginning? Alternatively, what's a good work around?
Hi, we are pleased to see that you are using our forum.
We'd like you to become a member of our community. Membership is FREE, please REGISTER and view our forums without these annoying reminders!
Once registered you may post on the forums, download from the file areas and use the WIKI without interruption.