I am using a AP32, and comunicating to a VDrive (from Vinculum) through the SCI port with Interrupts enabled.
Then I needed to store some variables to flash, and used the ROM Resident Routines.
Once read application note AN28741 and modified the RAM and ROM segments in the proyect.rpm file I had them up and running.
But then, when i wanted to make work both things together, it didn't. Saving and loading data from/into Flash worked fine, but SCI communication didn't. The problem was that the ROM Resident Routines disabled interrupts by setting the Interrupt Mask (I) in the CCR register.
So to avoid interrupts to be disabled i added the code in red to the example code from AN28741:
asm(TPA); // CCR to register A
asm(PSHA); // Push A onto Stack
asm(LDHX FILE_PTR); // Load address of RAM Data Block to H:X
asm(JSR ERARNGE); // Call ERARNGE ROM Subroutine
asm(PULA); // Pull A from Stack
asm(TAP); // A to CCR to restore Interrupt mask as it were.
For now it is working fine, but my question is if this is the best way of doing it. Is there a better way? Maybe I just neet to config some reg and i wont need the extra code. But i didn't fine anything in the forum. Any ideas?
Thanks in advance