interrupts

Status
Not open for further replies.
Code:
void rx_handler (void);//declare the ISR function.HIGH
void pull_chord (void);//declare the ISR function.LOW


//location of the ISR.(HIGH)
#pragma code rx_interrupt = 0x8
void rx_int (void)
{
  _asm goto rx_handler _endasm
}
#pragma code  //return to default code section


//location of the ISR.(LOW)
#pragma code low_pull = 0x18
void low_pull (void)
{
  _asm goto pull_chord _endasm
}
#pragma code  //return to default code section


is it something like this?
 
Yes, but as well you have to enable interrupt priorities (IPEN=1) and set the individual priority bits in IPR1 and IPR2 and the enable bits GIEL and GIEH.

Edit, there's an example(#7) in the C18 getting started pdf.

Mike.
 
Last edited:
Be careful. Interrupt preemption is not a good practice especially in C. It eats memory and usually does not provide any performance benefits.
 
Be careful. Interrupt preemption is not a good practice especially in C. It eats memory and usually does not provide any performance benefits.

This is not a multitasking environment. It is a simple interrupt on a microcontroller. You have no need to worry.

BTW, in what language is it a good practice?

Mike.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…