Hi everyone,
I was wondering if anybody could help me with building a vector table and also writing an interrupt service routine. I want to avoid using processor expert as much as possible. From what I've seen you can just build the table and then write the subroutines corresponding to the vectors.
However there are some things I'm not sure on. Such as how to reset the system, how to write the subroutine itself, and how to build the vector table.
If anybody could assist me on this it would be appreciated.
Solved! Go to Solution.
Hello
I assume you are building code for HC12 MCU.
In order to get working interrupts you need to:
1 - Tell the compiler the function is an interrupt function. This is done specifying #pragma TRAP_PROC prior to the function implementation or using the interrupt keyword.
Example
#pragma TRAP_PROC
void MY_Int(void){
}
or
__interrupt void MY_Int(void){
}
2 - If you are not building for small memory model, you also need to make sure the function is allocated in NON_BANKED memory.
In this purpose enclose the function implementation between
#pragma CODE_SEG __SHORT_SEG NON_BANKED
and
#pragma CODE_SEG DEFAULT
3 - Initialize the vector table entry with the address of the function. This is done in the .prm file using command VECTOR ADDRESS.
Example:
VECTOR ADDRESS 0xFFF0 MY_Int
4 - Initialize the peripheral appropriately and add code to enable the interrupt for the device.
5 - Make sure to enable the interrupts in your main function (you can use macro EnabelInterrupts from hidef.h in that purpose)
CrasyCat
Hello
I assume you are building code for HC12 MCU.
In order to get working interrupts you need to:
1 - Tell the compiler the function is an interrupt function. This is done specifying #pragma TRAP_PROC prior to the function implementation or using the interrupt keyword.
Example
#pragma TRAP_PROC
void MY_Int(void){
}
or
__interrupt void MY_Int(void){
}
2 - If you are not building for small memory model, you also need to make sure the function is allocated in NON_BANKED memory.
In this purpose enclose the function implementation between
#pragma CODE_SEG __SHORT_SEG NON_BANKED
and
#pragma CODE_SEG DEFAULT
3 - Initialize the vector table entry with the address of the function. This is done in the .prm file using command VECTOR ADDRESS.
Example:
VECTOR ADDRESS 0xFFF0 MY_Int
4 - Initialize the peripheral appropriately and add code to enable the interrupt for the device.
5 - Make sure to enable the interrupts in your main function (you can use macro EnabelInterrupts from hidef.h in that purpose)
CrasyCat