4

Do I have to disable high interrupts while inside one, if I am using multiple interrupts on the Microchip C18?

Consider the code below:

#ifndef OTHER_INTERRUPT_H
#pragma interrupt InterruptHook // interrupt fname
void InterruptHook(void)
{
    #ifdef STEPPER_H
        Stepper_Interrupt();
    #endif

    #ifdef FLOW_H
        Flow_Interrupt();
    #endif
}
#endif

Should I follow the same approach as in the code here below? (I would then put the disables in appropriate places within the functions.)

#ifndef OTHER_INTERRUPT_H
#pragma interrupt InterruptHook // interrupt fname
void InterruptHook(void)
{
    #ifdef STEPPER_H
        INTCONbits.GIEH = 0;
        Stepper_Interrupt();
        INTCONbits.GIEH = 1;
    #endif

    #ifdef FLOW_H
        INTCONbits.GIEH = 0;    
        Flow_Interrupt();
        INTCONbits.GIEH = 1;
    #endif
}
#endif
G-J
  • 107
  • 5
Christian
  • 1,548
  • 2
  • 15
  • 26

1 Answers1

2

It depends on the hardware. Some processors automatically disable interrupts while servicing one. Others prioritize their interrupts, so that a more high-priority interrupt can still occur while a lower is being serviced.

The Microchip PIC18 series microcontrollers feature multiple levels of hardware interrupts, and they can be optionally prioritized too.

unwind
  • 391,730
  • 64
  • 469
  • 606
  • hm.... this is code within high interrupt, two functions equally prioritised. I have one more pragma -> #pragma lowinterrupt InterruptHandler........ or maby I got it wrong so flow and stepper have different priorities whithin. – Christian Jan 07 '12 at 13:04