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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Table of Contents<br />

1 Introduction ..................................................................................................................................................... 1<br />

1.1 About QP ............................................................................................................................................... 2<br />

1.2 About QM .............................................................................................................................................. 3<br />

1.3 About this <strong>QDK</strong> ......................................................................................................................................... 3<br />

1.4 About the QP Port to <strong>PIC24</strong>/<strong>dsPIC</strong> ........................................................................................................ 4<br />

1.5 What’s Included in the <strong>QDK</strong>-<strong>PIC24</strong>-<strong>dsPIC</strong> .............................................................................................. 5<br />

1.6 Licensing QP ......................................................................................................................................... 5<br />

1.7 Licensing QM ........................................................................................................................................ 5<br />

2 Getting Started ................................................................................................................................................ 6<br />

2.1 Building the QP Libraries .......................................................................................................................... 8<br />

2.2 Building and Running the Examples ......................................................................................................... 9<br />

2.2.1 Building the Example Projects in the MPLABX IDE ........................................................................ 9<br />

2.2.2 Programming the Example to Run under the MPLAB Debugger ................................................... 9<br />

2.2.3 Collecting the QS software trace .................................................................................................... 10<br />

3 Cooperative “Vanilla” Port ............................................................................................................................. 12<br />

3.1 The qep_port.h Header File ...................................................................................................................... 12<br />

3.2 The qf_port.h Header File ......................................................................................................................... 12<br />

3.3 ISRs in the Non-Preemptive “Vanilla” Configuration ................................................................................. 14<br />

3.3.1 PSV Usage in ISRs ....................................................................................................................... 15<br />

3.3.2 Shadow Registers Usage in ISRs ................................................................................................. 15<br />

3.3.3 Assigning/Changing Interrupt Priorities in Software ....................................................................... 15<br />

3.4 QP Idle Loop Customization in QF_onIdle() .............................................................................................. 15<br />

4 Preemptive Configuration with QK ................................................................................................................ 17<br />

4.1 QK-specific ISR Entry and Exit Macros (file qk_port.h) ............................................................................. 17<br />

4.2 ISRs with the Preemptive QK Kernel ........................................................................................................ 19<br />

4.2.1 Explanation of ISR code for the preemptive QK kernel ................................................................. 20<br />

4.3 Idle Loop Customization in the QK Port .................................................................................................... 22<br />

4.4 Testing QK Preemption Scenarios ............................................................................................................ 23<br />

4.4.1 Interrupt Nesting Test ..................................................................................................................... 24<br />

4.4.2 Task Preemption Test .................................................................................................................... 24<br />

4.4.3 Other Tests .................................................................................................................................... 25<br />

5 Implementing “Zero Interrupt Latency” with the NMI .................................................................................. 26<br />

5.1 Communication between NMIs and QP .................................................................................................... 26<br />

5.2 Implementation Considerations for the NMIs ............................................................................................ 26<br />

6 BSP for the Microstick II Board ...................................................................................................................... 27<br />

6.1 Setting the Sizes of Stack and Heap ......................................................................................................... 27<br />

6.2 The BSP header file bsp.h ........................................................................................................................ 28<br />

6.3 BSP initialization ....................................................................................................................................... 28<br />

6.4 Starting Interrupts in QF_onStartup() ........................................................................................................ 28<br />

6.5 Assertion Handling Policy in Q_onAssert() ............................................................................................... 29<br />

7 The QS Software Tracing Instrumentation ................................................................................................... 30<br />

7.1 QS Time Stamp Callback QS_onGetTime() .............................................................................................. 31<br />

7.2 QS Trace Output in QF_onIdle()/QK_onIdle() ........................................................................................... 33<br />

7.3 Invoking the QSpy Host Application .......................................................................................................... 33<br />

8 Related Documents and References ............................................................................................................. 34<br />

9 Contact Information ........................................................................................................................................ 35<br />

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

i

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

Saved successfully!

Ooh no, something went wrong!