Hi Edward,
You are right.
I tested that approach in different situation – it was on S12Z and jump instruction was part of an application and not in the bootloader. That may be also some different type of workaround. The interface between bootloader and application will be just specific addresses where JMP instructions are located.
In application code something like:
#pragma CODE_SEG __NEAR_SEG NON_BANKED
/* ISR prototype */
typedef void (* tIsrFunc)(void);
typedef struct
{
byte jmp_instruction;
tIsrFunc address;
} InterruptTableEntry;
#define _VECTOR(v) {0x06U, &v}
InterruptTableEntry _InterruptVectorTable[INT_VECTOR_TABLE_SIZE] @INT_VECTOR_TABLE_ADDR_IN_FLASH = { /* Interrupt vector table */
_VECTOR(Unimplemented_ISR),//0x80
//…
//_VECTOR(Unimplemented_ISR),//
_VECTOR(API_ISR),//0x100
//….
_VECTOR(Unimplemented_ISR),//0x
};
#pragma CODE_SEG DEFAULT
That should create a table with fields containing JMP instruction and direct address to the application ISRs. The complication and advantage simultaneously are that calculating addresses for bootloader vector are not so straightforward (3 bytes per record). The advantage is that this vector table may be placed anywhere in nonbanked flash and order or number of implemented ISR records is also not limited (you may skip Reserved or unused interrupts) since it is not referenced by interrupt hardware directly.
In extreme case, this may be also done directly in linker file. Example for one interrupt vector.
ROM_JMP = READ_ONLY 0xC000 TO 0xC000 FILL 0x06; //asm JMP instruction
ROM_APP_VECTOR = READ_ONLY 0xC001 TO 0xC002; //space for vector address - see VECTOR ADDRESS ...
ROM_C000 = READ_ONLY 0xC003 TO 0xDF7F;
VECTOR ADDRESS 0xC001 API_ISR
The vector for API in bootloader should be filled by address 0xC000 in this case.
I hope it helps you.
Have a great day,
Radek
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------