QDK PIC24/dsPIC-C30 - Quantum Leaps
QDK PIC24/dsPIC-C30 - Quantum Leaps
QDK PIC24/dsPIC-C30 - Quantum Leaps
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>QDK</strong><br />
<strong>PIC24</strong>/<strong>dsPIC</strong>-<strong>C30</strong><br />
www.state-machine.com/pic<br />
(9) The QF_CRIT_STAT_TYPE macro is not defined, which means that the simple policy of “unconditional<br />
interrupt disabling and enabling” is applied (see Section 7.3 in [PSiCC2]).<br />
(10) The critical section entry macro disables interrupts (see step (7)).<br />
(11) The critical section exit macro unconditionally enables interrupts (see step (8)).<br />
3.3 ISRs in the Non-Preemptive “Vanilla” Configuration<br />
The MPLAB <strong>C30</strong> compiler supports writing interrupts in C. In the non-preemptive “vanilla” port, the ISRs<br />
are identical as in the simplest of all “superloop” (main+ISRs), and there is nothing QP-specific in the<br />
structure of the ISRs. The only QP-specific requirement is that you provide a periodic system clock tick<br />
ISR and you invoke QF_tick() in it. The ISRs are located in the bsp.c file found in the application<br />
directory.<br />
NOTE: The non-preemptive “vanilla” kernel allows interrupts nesting, as the interrupt preemptions<br />
are handled entirely by the <strong>PIC24</strong>/<strong>dsPIC</strong> hardware.<br />
Listing 4: The system tick interrupt calling QF_tick() function to manage armed time events.<br />
(1) void __attribute__((__interrupt__,<br />
(2) auto_psv))<br />
(3) _T2Interrupt(void)<br />
{<br />
(4) _T2IF = 0; /* clear Timer 2 interrupt flag */<br />
#ifdef Q_SPY<br />
(5) l_tickTime += BSP_TMR2_PERIOD; /* account for TMR2 overflow */<br />
#endif<br />
(6) QF_TICK(&l_T2Interrupt); /* handle all armed time events in QF */<br />
}<br />
/* perform other work, if necessary */<br />
(1) In the MPLAB <strong>C30</strong> The ISR must be declared with the attribute __interrupt__.<br />
(2) The auto_psv attribute will cause the compiler to preserve the previous contents of PSVPAG and<br />
set it to section .const. Upon exit, the previous value of PSVPAG will be restored. Alternatively, if<br />
the ISR does not access the PSVPAG access, the attribute no_auto_psv can be used (see Section<br />
8.10 in [MPLAB <strong>C30</strong>] for more details).<br />
NOTE: If you don’t explicitly specify the no_auto_psv attribute, the compiler will err on the safe side<br />
and will implicitly insert the auto_psv atribute.<br />
(3) Every ISR must be a void (void) function.<br />
(4) Most ISRs in the <strong>PIC24</strong>/<strong>dsPIC</strong> architecture must explicitly clear the interrupt flag for the interrupt<br />
source.<br />
(5) When software tracing is enabled, the ISR updates the 32-bit time stamp at tick, which is used to<br />
provide a 32-bit time stamp for the trace events.<br />
Copyright © <strong>Quantum</strong> <strong>Leaps</strong>, LLC. All Rights Reserved.<br />
14 of 35