Hi
There are three ways to momentarily disable/re-enable interrupts.
1. Globally by using
uDisable_Interrupt();
..
uEnable_Interrupt();
2. By disabling only the port interrupt source:
fnMaskInterrupt(irq_PORTB_ID);
...
fnUnmaskInterrupt(irq_PORTB_ID);
3. By disabling only a single port interrupt source:
_DIS_ARM_PORT_INTERRUPT(B, INTERRUPT_PIN); // example of disabling the interrupt
...
_RE_ARM_PORT_INTERRUPT(B, INTERRUPT_PIN, PORT_IRQC_RISING); // example of re-enabling or changing its sensitivity
It is possible that some of these are missing in the open source version at the moment so these are the sources/macros in case something is missing.
// Macros for disabling port interrupt and re-arming (or changing sensitivity)
//
#define _DIS_ARM_PORT_INTERRUPT(port, bit) PORT##port##_PCR##bit &= ~(PORT_IRQC_INT_MASK)
#define _RE_ARM_PORT_INTERRUPT(port, bit, sense) PORT##port##_PCR##bit = ((PORT##port##_PCR##bit & ~(PORT_IRQC_INT_MASK)) | (sense))
extern void fnMaskInterrupt(int iInterruptID)
{
#if defined _WINDOWS // back up the present enabled interrupt registers
IRQ0_31_CER = IRQ32_63_CER = IRQ64_95_CER = 0; // reset registers
#endif
volatile unsigned long *ptrIntMask = IRQ0_31_CER_ADD;
ptrIntMask += (iInterruptID/32); // move to the clear enable register in which this interrupt is controlled
*ptrIntMask = (0x01 << (iInterruptID % 32)); // disable the interrupt
#if defined _WINDOWS
IRQ0_31_SER &= ~IRQ0_31_CER; // synchronise the interrupt masks
IRQ32_63_SER &= ~IRQ32_63_CER;
IRQ64_95_SER &= ~IRQ64_95_CER;
IRQ0_31_CER = IRQ0_31_SER;
IRQ32_63_CER = IRQ32_63_SER;
IRQ64_95_CER = IRQ64_95_SER;
#endif
}
extern void fnUnmaskInterrupt(int iInterruptID)
{
#if defined _WINDOWS // back up the present enabled interrupt registers
unsigned long ulState0 = IRQ0_31_SER;
unsigned long ulState1 = IRQ32_63_SER;
unsigned long ulState2 = IRQ64_95_SER;
IRQ0_31_SER = IRQ32_63_SER = IRQ64_95_SER = IRQ0_31_CER = IRQ32_63_CER = IRQ64_95_CER = 0; // reset registers
#endif
volatile unsigned long *ptrIntSet = IRQ0_31_SER_ADD;
ptrIntSet += (iInterruptID / 32); // move to the clear enable register in which this interrupt is controlled
*ptrIntSet = (0x01 << (iInterruptID % 32)); // enable the interrupt
#if defined _WINDOWS
IRQ0_31_SER |= ulState0; // synchronise the interrupt masks
IRQ32_63_SER |= ulState1;
IRQ64_95_SER |= ulState2;
IRQ0_31_CER = IRQ0_31_SER;
IRQ32_63_CER = IRQ32_63_SER;
IRQ64_95_CER = IRQ64_95_SER;
#endif
}
Regards
Mark