I'm using a PIC24EP512GP806 and I'm writing some ASM30 code in the auxiliary flash section but I'm having a lot of trouble with the CALL instruction.
When this code is run from auxiliary flash, as soon as it gets to the CALL instruction, the chip appears to reset (neither LED lights up).Code:CALL sub_error BSET led_lat, #led_lat_bit GOTO $ ; Subroutine error sub_error: BSET led_lat, #led_lat_bit BSET led2_lat, #led2_lat_bit GOTO $
If I use BRA instead of CALL then it works as expected.
If I run the above code from the normal area of flash then it works.
I've confirmed it's at least getting to the CALL instruction.
Watchdog is disabled.
I believe there may be some issue with the CALL instruction handling large addresses. sub_error is located at 0x7FC10E but the Programmer's Reference Manual says it can handle 23-bit addresses.
There are no compiler errors or warnings to suggest there's anything wrong with the code. I've also checked the errata sheet for this chip and can't see anything that could cause this issue.
I've tried Googling but I can't find anything remotely useful and I'm at a loss for what to try next.
Bookmarks