QDK Freertos.Org Is Config- Ured to Operate in Preemptive Mode
Total Page:16
File Type:pdf, Size:1020Kb
QP state machine frameworks for FreeRTOS.org™ QDK™ FreeRTOS.org™ Document Revision B September 2008 Copyright © Quantum Leaps, LLC www.quantum-leaps.com www.state-machine.com Table of Contents 1 Introduction.................................................................................................... 1 1.1 What’s Included in the QDK-FreeRTOS? ............................................................... 2 1.2 Licensing QDK-MSP430-IAR................................................................................ 2 2 Getting Started ............................................................................................... 3 2.1 Installation ...................................................................................................... 3 2.2 Building the QP Libraries .................................................................................... 4 2.3 Building the Examples ....................................................................................... 5 2.4 Running the Examples ....................................................................................... 6 2.4.1 Minimal FreeRTOS.org Demo Application ........................................................ 7 2.4.2 Dining Philosopher Problem (DPP) Example Application .................................... 7 3 The Modified FreeRTOS.org Port STR9x_IAR................................................... 9 3.1 Augmented FreeRTOS.org Interrupt Processing ..................................................... 9 3.2 General Limitations of FreeRTOS.org Ports.......................................................... 10 3.3 Changes in the portmacro.h file......................................................................... 10 3.4 Changes in the port.c File................................................................................ 13 3.5 Demo Application for the Updated FreeRTOS.org Port........................................... 14 4 The QP Port to FreeRTOS.org ........................................................................ 15 4.1 The FreeRTOSConfig.h Header File .................................................................... 15 4.2 The qep_port.h Header File .............................................................................. 16 4.3 The qf_port.h Header File................................................................................. 16 4.3.1 The Active Object Event Queue and Thread .................................................. 17 4.3.2 The QF Critical Section .............................................................................. 17 4.3.3 FreeRTOS.org Include Files ........................................................................ 17 4.3.4 QP Include Files........................................................................................ 17 4.3.5 Memory Pool ............................................................................................ 18 4.4 The qf_port.c Source File ................................................................................. 18 4.5 ARM/THUMB Compilation ................................................................................. 22 5 The Example QP Application.......................................................................... 23 5.1 The main() Function........................................................................................ 23 5.2 ISRs ............................................................................................................. 24 5.3 Starting Interrupts in vStartInterrupts()............................................................. 25 5.4 Idle Processing in vApplicationIdleHook() ........................................................... 25 5.5 Assertion Handling Policy in Q_onAssert() .......................................................... 26 6 The Quantum Spy (QS) Instrumentation....................................................... 27 6.1 QS Time Stamp Callback QS_onGetTime().......................................................... 29 6.2 Invoking the QSpy Host Application ................................................................... 30 7 Related Documents and References .............................................................. 31 8 Contact Information...................................................................................... 32 Copyright © Quantum Leaps, LLC. All Rights Reserved. i 1 Introduction This QP™ Development Kit (QDK) describes how to use QP™ event-driven platform with the FreeRTOS.org™ real-time kernel. The actual hardware/software used in this QDK is described be- low (see also Figure 1): 1. IAR STR912-SK board with STR912F device (ARM966E-S core, 96KB RAM, 512KB ROM). 2. IAR Embedded Workbench for ARM (EWARM) KickStart edition version 5.11. 3. FreeRTOS.org™ version 5.0.0 or higher. 4. QP/C/C++ v4.0 or higher. QS trace data J-Link USB (UART0) LED/Peripheral Debugger Jumpers Two groups of user LEDs 8 LEDs each STR912F Target Device USB to PC External Power source power selection Jumper Figure 1 IAR STR912-SK evaluation board with the J-Link JTAG pod. Copyright © Quantum Leaps, LLC. All Rights Reserved. 1 of 32 QDK™ FreeRTOS.org™ www.state-machine.com/freertos As shown in Figure 1, the STR912-SK board is connected via a 20-pin ribbon cable to the J-Link USB debugger. Additionally, the UART0 connector of the STR912-SK board is used in this QDK for QS (“Spy”) software tracing of the live QP applications. You need a straight serial cable with DB9 connectors to connect UART0 to the COM port of your PC. NOTE: Even though the QDK uses a specific target board (STR912-SK in this case), the QDK has been designed generically to rely on the FreeRTOS.org™ to access the hardware. In other words, the QDK should require minimal adaptation for any other platform supported by FreeR- TOS.org™. 1.1 What’s Included in the QDK-FreeRTOS? This QDK provides a modified FreeRTOS port to STR91-IAR, a minimal demo application that tests this updated FreeRTOS.org port, as well as QP port to FreeRTOS and the Dining Philosopher Prob- lem (DPP) application to test the QP port to FreeRTOS. The DPP example application is described in the Application Note “Dining Philosophers Application” [QL AN-DPP 08] (included in this DPP). The DPP application also demonstrates the QS (“Spy”) software tracing. NOTE: This QDK covers both the C and C++ version of QP. The concrete code examples are taken from the C version, but the C++ version is essentially identical except for some trivial syntax differences. 1.2 Licensing QDK-MSP430-IAR The Generally Available (GA) distribution of QDK-MSP430-IAR available for download from the www.quantum-leaps.com/msp430 website is offered with the following two licensing options: • The GNU General Public License version 2 (GPL) as published by the Free Software Foundation and appearing in the file GPL.TXT included in the packag- ing of every Quantum Leaps software distribution. The GPL open source li- cense allows you to use the software at no charge under the condition that if you redistribute the original software or applications derived from it, the com- plete source code for your application must be also available under the condi- tions of the GPL (GPL Section 2[b]). • One of several Quantum Leaps commercial licenses, which are designed for customers who wish to retain the proprietary status of their code and therefore cannot use the GNU General Public License. The customers who license Quantum Leaps software under the commercial li- censes do not use the software under the GPL and therefore are not subject to any of its terms. For more information, please visit the licensing section of our website at: www.quantum- leaps.com/licensing. Copyright © Quantum Leaps, LLC. All Rights Reserved. 2 of 32 QDK™ FreeRTOS.org™ www.state-machine.com/freertos 2 Getting Started This section describes how to install, build, and use QDK-FreeRTOS. This information is intention- ally included early in this document, so that you could start using the QDK as soon as possible. NOTE: This QDK assumes that the standard QP distribution, consisting of QEP, QF, and QS, has been installed, before installing this QDK. It is also strongly recommended that you read the QP Tutorial (www.quantum-leaps.com/doxygen/qpc/tutorial_page.html) before you start ex- perimenting with this QDK. 2.1 Installation The QDK code is distributed in a ZIP archive (qdkc_freertos_<ver>.zip, where <ver> stands for a specific QDK-FreeRTOS version, such as 4.0.01). You should uncompress the archive into the same directory into which you’ve installed all the standard QP components. The installation directory you choose will be referred henceforth as QP Root Directory (<qp>). The following Listing 1 shows the directory structure and selected files included in the QDK-FreeRTOS distribution. (Please note that the QP directory structure is described in detail in a separate Application Note: “QP Directory Struc- ture” [QL AN-Directory 07]): doc\ - Documentation for this QDK | +-AN_DPP.pdf - Application Note “Dining Philosophers Application” +-QDK_FreeRTOS.pdf - This “QDK Programmer’s Manual” FreeRTOS/ - FreeRTOS.org root directory | +-Demo/ - FreeRTOS.org demo applicaitons | +-ARM9_STR91X_IAR_light/ – Modified ARM9_STR91X_IAR demo application | | +-main.c – the main() function of the application | | +-FreeRTOSConfig.h – FreeRTOS configuration | | +-RTOSDemo.eww – IAR workspace to build the application | | +-. – other files in the application | +-Source/ - FreeRTOS.org source files | +-portable/ – FreeRTOS.org ports | | +-IAR/ – ports