17.01.2015 Views

QDK PIC24/dsPIC-XC16 - Quantum Leaps

QDK PIC24/dsPIC-XC16 - Quantum Leaps

QDK PIC24/dsPIC-XC16 - Quantum Leaps

SHOW MORE
SHOW LESS

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>XC16</strong><br />

www.state-machine.com/pic<br />

3 Cooperative “Vanilla” Port<br />

The “vanilla” port shows how to use QP on a bare metal <strong>PIC24</strong>-<strong>dsPIC</strong>-based system with the<br />

cooperative “vanilla” kernel. In this version you’re using the non-preemptive kernel built-into the QF<br />

framework and your’e not using the QK component.<br />

3.1 The qep_port.h Header File<br />

The QEP header file for the <strong>PIC24</strong>/<strong>dsPIC</strong> port is located in \ports\pic24-<br />

dspic\vanilla\xc16\qep_port.h. Listing 2 shows the qep_port.h header file for <strong>PIC24</strong>/<strong>dsPIC</strong>.<br />

NOTE: The QP port to the cooperative “Vanilla” kernel qep_port.h is generic and should not need<br />

to change for other <strong>PIC24</strong>/<strong>dsPIC</strong> applications.<br />

Listing 2: qep_port.h header file for the cooperative QP configuration and <strong>XC16</strong> compiler<br />

#ifndef qep_port_h<br />

#define qep_port_h<br />

/* Exact-width types. WG14/N843 C99 Standard, Section 7.18.1.1 */<br />

(1) #include <br />

#include "qep.h" /* QEP platform-independent public interface */<br />

#endif /* qep_port_h */<br />

(1) The <strong>XC16</strong> compiler support the C99 exact-width integer types the standard header file.<br />

3.2 The qf_port.h Header File<br />

The QF header file for the <strong>PIC24</strong>/<strong>dsPIC</strong> port is located in \ports\pic24-dspic\<br />

vanilla\xc16\qf_port.h. This file specifies the interrupt locking/unlocking policy (QF critical section)<br />

as well as the configuration constants for QF (see Chapter 8 in [PSiCC2]).<br />

The most important porting decision you need to make in the qf_port.h header file is the policy for<br />

locking and unlocking interrupts. The <strong>PIC24</strong>/<strong>dsPIC</strong> CPU allows using the simplest “unconditional interrupt<br />

unlocking” policy (see Section 7.3.2 of the book “Practical UML Statecharts in C/C++, Second Edition”<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 />

Copyright © <strong>Quantum</strong> <strong>Leaps</strong>, LLC. All Rights Reserved.<br />

12 of 35

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!