Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

pic18fxx and interupt

Status
Not open for further replies.

ect_09

New Member
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.
 
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.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top