Mikroelektronika MIKROE-738 Datenbogen

Seite von 682
142
mikoC PRO for PIC32
MikroElektronika
Interrupt Priorities
In the Multi Vector Mode, the user is able to assign a 
group priority and group subpriority level to each of the 
interrupt vectors. The user-selectable priority levels range from 1 (the lowest priority) to 7 (the highest). 
If an interrupt priority is set to zero, the interrupt vector is disabled for both interrupt and wake-up purposes. Interrupt 
vectors with a higher priority level preempt lower priority interrupts.
The subpriority will cause that when two interrupts with the same priority are pending, the interrupt with the highest 
subpriority will be handled first. The user-selectable subpriority levels range from 0 (the lowest subpriority) to 3 (the 
highest).
Interrupts and Register Sets
The PIC32MX family of devices employs two register sets, a 
primary register set for normal program execution and a 
shadow register set for highest priority interrupt processing.
 
Register Set Selection in Single Vector Mode
 
In Single Vector mode, you can select which register set will be used. By default, the interrupt controller will  
 
instruct the CPU to use the first register set. This can be changed later in the code.
 
Interrupts and Register Sets
 
When a priority level interrupt matches a shadow set priority, the interrupt controller instructs the CPU to use  
 
the shadow set. For all other interrupt priorities, the interrupt controller instructs the CPU to use the primary  
 
register set. 
Interrupt Coding Requirements
In order to correctly utilize interrupts and correctly write the ISR code, the user will need to take care of these things:
 
1. Write the Interrupt Service Routine. You may use Interrupt Assistant to easily write this routine. 
 
2. Initialize the module which will generate an interrupt. 
 
3. Set the correct priority and subpriority for the used module according to the priorities set in the Interrupt  
 
    Service Routine. 
 
4. Enable Interrupts. 
Interrupt Service Routine
Interrupt service routine is defined in this way: 
void interrupt() iv IVT_ADC ilevel 7 ics ICS_SOFT {
  // Interrupt service routine code
}