QDK PIC24/dsPIC-C30 - Quantum Leaps
QDK PIC24/dsPIC-C30 - Quantum Leaps
QDK PIC24/dsPIC-C30 - Quantum Leaps
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>QDK</strong><br />
<strong>PIC24</strong>/<strong>dsPIC</strong>-<strong>C30</strong><br />
www.state-machine.com/pic<br />
[PSiCC2]), because <strong>PIC24</strong>/<strong>dsPIC</strong> can mask interrupt groups (INT1 - INT12) and individual interrupts in<br />
the Peripheral Interrupt Expansion (PIE) module. Listing 3 shows the qf_port.h header file for<br />
<strong>PIC24</strong>/<strong>dsPIC</strong>.<br />
Listing 3: The qf_port.h header file for <strong>PIC24</strong>/<strong>dsPIC</strong>.<br />
/* The maximum number of active objects in the application, see NOTE01 */<br />
(1) #define QF_MAX_ACTIVE 8<br />
(2) #define QF_EVENT_SIZ_SIZE 1<br />
(3) #define QF_EQUEUE_CTR_SIZE 1<br />
(4) #define QF_MPOOL_SIZ_SIZE 1<br />
(5) #define QF_MPOOL_CTR_SIZE 1<br />
(6) #define QF_TIMEEVT_CTR_SIZE 2<br />
/* QF interrupt disable/enable, see NOTE02 */<br />
(7) #define QF_INT_DISABLE() __asm__ volatile("disi #0x3FFF")<br />
(8) #define QF_INT_ENABLE() __asm__ volatile("disi #0x0000")<br />
/* QF critical section entry/exit, see NOTE02 */<br />
(9) /* QF_CRIT_STAT_TYPE not defined: unconditional interrupt unlocking" policy */<br />
(10) #define QF_CRIT_ENTRY(dummy) __asm__ volatile("disi #0x3FFF")<br />
(11) #define QF_CRIT_EXIT(dummy) __asm__ volatile("disi #0x0000")<br />
#include "qep_port.h" /* QEP port */<br />
#include "qvanilla.h" /* "Vanilla" cooperative kernel */<br />
#include "qf.h" /* QF platform-independent public interface */<br />
(1) The QF_MAX_ACTIVE specifies the maximum number of active object priorities in the application.<br />
You always need to provide this constant in the QF port. Here, QF_MAX_ACTIVE is set to 8 to<br />
conserve some RAM, but you can increase this value up to 63 inclusive.<br />
(2-5) These object sizes in QF are all set to 1, meaning that uint8_t will be used to represent the various<br />
object sizes.<br />
NOTE: Please refer to Chapter 8 of [PSiCC2] for discussion of all configurable QF parameters.<br />
(6) These time event counter is configured to 2-bytes, meaning that timeouts of up to 65535 clock ticks<br />
can be handled in this QF port.<br />
(7) The interrupt disable macro resolves to the single instruction DISI #0x3FFF, which disables<br />
interrupts for 16383 instruction cycles. The number of cycles is much longer than any actual critical<br />
section in QP.<br />
NOTE: The DISI instruction only disables interrupts with priority levels 1-6. Priority level 7 interrupts<br />
and all trap events still have the ability to interrupt the CPU when the DISI instruction is active. This<br />
means that from the perspective of QP, the level 7 interrupts are treated as non-maskable interrupts<br />
(NMIs). Such non-maskable interrupts cannot call any QP services. In particular, they cannot post<br />
events (see also Section 5).<br />
(8) The DISI #0 instruction is then used to unconditionally unlock the interrupts at the end of the critical<br />
section.<br />
Copyright © <strong>Quantum</strong> <strong>Leaps</strong>, LLC. All Rights Reserved.<br />
13 of 35