I have an mplabx project with a custom bootloader and application for the PIC32MX795F512L. All throughout its development, I have been jumping from the bootloader to the application with no problem using the line:
((void (*)(void))(APPLICATION_RESET_ADDRESS))();
where APPLICATION_RESET_ADDRESS
is a macro with the address of the reset handler for my application. After some recent modifications to the bootloader, I suddenly started getting into the general exception handler sometime after executing that line and before getting into the main
function of the application. the odd thing is, if I set a breakpoint on that line and then continue after breaking it works fine. further more, if I change the way I jump to the application to:
asm volatile
(
"JALR %0"
:
:"r"(APPLICATION_RESET_ADDRESS)
:
);
it jumps to the application with no problem which is really confusing because the assembly generated by: ((void (*)(void))(APPLICATION_RESET_ADDRESS))();
is
LUI v0,-25341
ADDIU V0, V0, -28672
JALR V0
NOP
and the assembly generated by:
asm volatile
(
"JALR %0"
:
:"r"(APPLICATION_RESET_ADDRESS)
:
);
is
LUI V0, -25342
ORI V0, V0, -28672
JALR V0
NOP
so both methods use the same number of instructions, and both jump using JALR the only difference between the 2 is how they load the pointer into the register. does anyone have any ideas?