Vault 7: Projects
This publication series is about specific projects related to the Vault 7 main publication.
Interrupts
2012-2013 Microchip Technology Inc. DS50002071C-page 201
14.8.1.3 APPLICATION EXAMPLE
The following example highlights some of the points discussed in this section:
void __attribute__((interrupt))
HigherPriorityInterrupt(void) {
/* User Code Here */
LATGbits.LATG15 = 1; /* Set LATG bit 15 */
IPC0bits.INT0IP = 2; /* Set Interrupt 0
priority (multiple
bits involved) to 2 */
}
int main(void) {
/* More User Code */
LATGbits.LATG10 ^= 1; /* Potential HAZARD -
First reads LATG into a W reg,
implements XOR operation,
then writes result to LATG */
LATG = 0x1238; /* No problem, this is a write
only assignment operation */
LATGbits.LATG5 = 1; /* No problem likely,
this is an assignment of a
single bit and will use a single
instruction bit set operation */
LATGbits.LATG2 = 0; /* No problem likely,
single instruction bit clear
operation probably used */
LATG += 0x0001; /* Potential HAZARD -
First reads LATG into a W reg,
implements add operation,
then writes result to LATG */
IPC0bits.T1IP = 5; /* HAZARD -
Assigning a multiple bitfield
can generate a multiple
instruction sequence */
}
A statement can be protected from interrupt using the INTERRUPT_PROTECT macro
provided above. For this example:
INTERRUPT_PROTECT(LATGbits.LATG15 ^= 1); /* Not interruptible by
level 1-7 interrupt
requests and safe
at any optimization
level */
Protego_Release_01_05-Related-OEM-Documentation-MPLAB-XC16-C-Compiler.pdf