TNeoKernel
v1.04
|
PIC32 port implementation details
The context switch is implemented using the core software 0 interrupt (CS0
), which is configured by the kernel to the lowest priority (1). This interrupt is handled completely by the kernel, application should never touch it.
The interrupt priority level 1 should not be configured to use shadow register sets.
Multi-vectored interrupt mode should be enabled.
src/arch/pic32/tn_arch_pic32_int_vec1.S
must be included in the main project itself, in order to dispatch vector1 (core software interrupt 0) correctly. Do note that if we include this file in the TNeoKernel library project, it doesn't work for vector, unfortunately._DefaultInterrupt
when it's time to switch context.For generic information about interrupts in TNeoKernel, refer to the page Interrupts.
PIC32 port has system interrupts only, there are no user interrupts.
PIC32 port supports nested interrupts. The kernel provides C-language macros for calling C-language interrupt service routines, which can use either MIPS32 or MIPS16e mode. Both software and shadow register interrupt context saving is supported. Usage is as follows:
In spite of the fact that the kernel provides separate stack for interrupt, this isn't a mandatory on PIC32: you're able to define your ISR in a standard way, making it use stask of interrupted task and work a bit faster. Like this:
There is always a tradeoff. There are no additional constraints on ISR defined without kernel-provided macro: in either ISR, you can call the same set of kernel services.
When you make a decision on whether particular ISR should use separate stack, consider the following:
For generic information on building TNeoKernel, refer to the page Building the project.
MPLABX project for PIC32 port resides in the src/arch/pic32/tneokernel_pic32.X
directory. This is a library project in terms of MPLABX, so if you use MPLABX you can easily add it to your main project by right-clicking Libraries -> Add Library Project ...
. Alternatively, of course you can just build it and use resulting tneokernel_pic32.X.a
file in whatever way you like.