E ect_09 New Member Jul 19, 2012 #1 Hi i studied Pic 18f458 interupts. i use 1-#pragma interrupt chk_isr void chk_isr(void) 2-#pragma code my_HiPrio_int=0x08 void my_HiPrio_int(void) 3-#pragma code void main() please tell me why we use it.
Hi i studied Pic 18f458 interupts. i use 1-#pragma interrupt chk_isr void chk_isr(void) 2-#pragma code my_HiPrio_int=0x08 void my_HiPrio_int(void) 3-#pragma code void main() please tell me why we use it.
Ian Rogers User Extraordinaire Forum Supporter Most Helpful Member Jul 19, 2012 #2 The correct way to declare an interrupt in C18 is:- Code: #pragma code InterruptVectorHigh = 0x08 This instructs the compiler to the CODE section at address 0x08 ( low interrupt vector ) Code: void InterruptVectorHigh (void) { _asm goto InterruptHandlerHigh //jump to interrupt routine _endasm } This places the new vector in that code space (InterruptHandlerHigh can be any function identifier ) Now vector 0x08 in code will hold the jump call to YOUR interrupt routine. Code: #pragma code #pragma interrupt InterruptHandlerHigh void InterruptHandlerHigh () { // your code here... } The final piece, is a function in CODE space that contains the code that needs executing when a interrupt is fired.
The correct way to declare an interrupt in C18 is:- Code: #pragma code InterruptVectorHigh = 0x08 This instructs the compiler to the CODE section at address 0x08 ( low interrupt vector ) Code: void InterruptVectorHigh (void) { _asm goto InterruptHandlerHigh //jump to interrupt routine _endasm } This places the new vector in that code space (InterruptHandlerHigh can be any function identifier ) Now vector 0x08 in code will hold the jump call to YOUR interrupt routine. Code: #pragma code #pragma interrupt InterruptHandlerHigh void InterruptHandlerHigh () { // your code here... } The final piece, is a function in CODE space that contains the code that needs executing when a interrupt is fired.