Currently the Netcruzer system uses co-operative task scheduling. It is not a real multitasking system, and uses state machines in tasks.
In the future, it might be extended to a real multi taking system. Interrupt level 1 is reserved for the "Kernel Scheduler", and interrupt level 2 for the "Kernel Timer".
Each interrupt can be assigned an interrupt level from 1 to 7 (0 is disabled). In addition, interrupts have a natural interrupt level. If two interrupts assigned the same interrupt level are active, the one with the highest natural level will be processed. For example, the natural interrupt level of the Timer 1 interrupt is 3, which is very high. Only the Capture/Compare Module 1 has an higher natural priority. The interrupt levels used are (7 has highest priority):
Level 7:
- Available for user Interrupts! Only use for highest priority interrupt, that stay in ISR for a very short time!
Level 6:
- Available for user Interrupts! Only use for high priority interrupt, that stay in ISR for a short time!
Level 5:
- Available for user Interrupts! Only use for high priority interrupt, that stay in ISR for a very short time!
- System tick (NP=3), uses TMR1. Set by nzINT_PRIORITY_TICK define in projdefs.h. Calls "Netcruzer RTOS" nzRtosTick().
Level 4:
- Available for user Interrupts!
- UART1 (NP=11&12). Set by nzINT_PRIORITY_UART1 define in projdefs.h
- Analog to Digital Converter (NP=13). Set by nzINT_PRIORITY_ADC1 define in projdefs.h
- UART2 (NP=30&31). Set by nzINT_PRIORITY_UART2 define in projdefs.h
- UART3 (NP=82&83). Set by nzINT_PRIORITY_UART3 define in projdefs.h
- UART4 (NP=88&89). Set by nzINT_PRIORITY_UART4 define in projdefs.h
Level 3:
- Available for user Interrupts!
- I2C 1 Master (NP=17). Set by nzINT_PRIORITY_I2C1 define in projdefs.h
- I2C 2 Master (NP=50). Set by nzINT_PRIORITY_I2C2 define in projdefs.h
- I2C 3 Master (NP=85). Set by nzINT_PRIORITY_I2C3 define in projdefs.h
- USB (NP=86). Set with USB1IP in usb_hal_pic24E.h and usb_hal_dspic33E.h
Level 2:
- Available for user Interrupts! Use for interrupts that have very low priority, and stay long in the ISR.
Level 1:
- Used by "Netcruzer RTOS" for "RTOS Kernel" and "Fiber Tasks". Uses "I2C 1 Slave" (NP=16) Interrupt by default.
Level 0:
- Used by "Netcruzer RTOS" for Tasks and "FSM Tasks"
Where (NP=n) gives natural priority. See description above for details.