|
| 1 | +> **NOTE** |
| 2 | +This file is best viewed in a **markdown viewer**, such as the one built into GitHub. Markdown viewers are also available as plug-ins to popular Internet browsers. |
| 3 | + |
| 4 | +# DPP on NUCLEO-C031C6 |
| 5 | +This example demonstrates the [Dining Philosophers Problem (DPP) application](https://www.state-machine.com/qpc/tut_dpp.html) on the STM32 NUCLEO-C031C6 board (ARM Cortex-M0+). |
| 6 | + |
| 7 | +<p align="center"> |
| 8 | +<img src="./stm32-nucleo-c031c6.jpg"/><br> |
| 9 | +<b>STM32 NUCLEO-C031C6</b> |
| 10 | +</p> |
| 11 | + |
| 12 | +> **NOTE** |
| 13 | +This example can be used as a starting point for any other ARM Cortex-M MCU, including those based on different Cortex-M cores (M0/M0+/M3/M4/M7/M23/M33/M55/M85...) The most simplifying factor is that the QP-ports to Cortex-M don't need to change at all (the correct port is selected automatically based on the standard preprocessor macros provided by the compiler). |
| 14 | + |
| 15 | +<p align="center"> |
| 16 | +<img src="../qp_arm-cm.jpg"/> |
| 17 | +</p> |
| 18 | + |
| 19 | +## Features Demonstrated |
| 20 | +- multiple cooperating active objects |
| 21 | +- immutable (const) events |
| 22 | +- mutable (dynamic) events |
| 23 | +- time events |
| 24 | +- direct event posting |
| 25 | +- publish-subscribe event delivery |
| 26 | +- cooperative QV kernel |
| 27 | + + with ARM-KEIL toolchain |
| 28 | + + with GNU-ARM toolchain |
| 29 | + + with IAR-ARM toolchain |
| 30 | +- preemptive run-to-completion QK kernel |
| 31 | + + with ARM-KEIL toolchain |
| 32 | + + with GNU-ARM toolchain |
| 33 | + + with IAR-ARM toolchain |
| 34 | +- preemptive dual-mode QXK kernel |
| 35 | + + with ARM-KEIL toolchain |
| 36 | + + with GNU-ARM toolchain |
| 37 | + + with IAR-ARM toolchain |
| 38 | + |
| 39 | +## Build Configurations |
| 40 | +- Debug |
| 41 | +- Release |
| 42 | +- Spy - software tracing with the built-in virtual COM port |
| 43 | + |
| 44 | +# Code Organization |
| 45 | +``` |
| 46 | +examples\arm-cm\dpp_nucleo-c031c6 |
| 47 | +| |
| 48 | ++---qk // preemptive QK kernel |
| 49 | +| +---gnu // GNU-ARM toolchain |
| 50 | +| | \---targetConfigs |
| 51 | +| | Makefile // Makefile for GNU-ARM |
| 52 | +| +---armclang // ARM/KEIL toolchain with Compiler 6 (ARM/CLANG) |
| 53 | +| | dpp-qk.uvprojx // uVision project |
| 54 | +| \---iar // IAR EWARM |
| 55 | +| dpp-qk.eww // IAR EW-ARM workspace |
| 56 | +| |
| 57 | +\---qv // cooperative QK kernel |
| 58 | +| +---gnu // GNU-ARM toolchain |
| 59 | +| | \---targetConfigs |
| 60 | +| | Makefile // Makefile for GNU-ARM |
| 61 | +| +---armclang // ARM/KEIL toolchain with Compiler 6 (ARM/CLANG) |
| 62 | +| | dpp-qv.uvprojx // uVision project |
| 63 | +| \---iar // IAR EWARM |
| 64 | +| dpp-qv.eww // IAR EW-ARM workspace |
| 65 | +| |
| 66 | ++---qxk // preemptive, dual-mode QXK kernel |
| 67 | +| +---gnu // GNU-ARM toolchain |
| 68 | +| | \---targetConfigs |
| 69 | +| | Makefile // Makefile for GNU-ARM |
| 70 | +| +---armclang // ARM/KEIL toolchain with Compiler 6 (ARM/CLANG) |
| 71 | +| | dpp-qxk.uvprojx // uVision project |
| 72 | +| \---iar // IAR EWARM |
| 73 | +| dpp-qxk.eww // IAR EW-ARM workspace |
| 74 | +| |
| 75 | +``` |
| 76 | + |
| 77 | +# Building the example |
| 78 | + |
| 79 | +### GNU/ARM |
| 80 | +- open terminal window |
| 81 | +- change to the desired directory (either `examples\arm-cm\dpp_nucleo-c031c6\qk\gnu`, `examples\arm-cm\dpp_nucleo-c031c6\qv\gnu`, or `examples\arm-cm\dpp_nucleo-c031c6\qxk\gnu`) |
| 82 | +- to build the default Debug configuration, type: |
| 83 | + |
| 84 | +``` |
| 85 | +make |
| 86 | +``` |
| 87 | + |
| 88 | +> **NOTE** |
| 89 | +The `make` utility for Windows is provided in the QTools collection for Windows. |
| 90 | + |
| 91 | +- to build the Release configuration, type: |
| 92 | + |
| 93 | +``` |
| 94 | +make CONF=rel |
| 95 | +``` |
| 96 | + |
| 97 | +- to build the Spy configuration, type: |
| 98 | + |
| 99 | +``` |
| 100 | +make CONF=spy |
| 101 | +``` |
| 102 | + |
| 103 | + |
| 104 | +### ARM/KEIL MDK |
| 105 | +- Open the provided KEIL uVision project (either `dpp-qk.uvprojx`, `dpp-qv.uvprojx`, or `dpp-qxk.uvprojx`) |
| 106 | +in Keil uVision IDE. Build/Debug/Download to the board from the IDE. |
| 107 | +- Change the build configuration in the "Project Target" drop-down menu. |
| 108 | + |
| 109 | + |
| 110 | +### IAR EWARM |
| 111 | +- Open the provided IAR EWARM workspace (either `dpp-qk.eww`, `dpp-qv.eww`, or `dpp-qxk.eww`) |
| 112 | +in IAR EWARM IDE. Build/Debug/Download to the board from the IDE. |
| 113 | +- Change the build configuration in the "Project Configuration" drop-down menu. |
| 114 | + |
| 115 | + |
| 116 | +# Uploading the Binary to the Board |
| 117 | +The STM32 NUCLEO boards enumerate as a USB drive when connected to the host computer. The boards then can be programmed by **copying** the binary to that USB drive. This can be useful for the command-line GNU/ARM build. For example, to program the binary produced for the Debug configuration, you can type: |
| 118 | + |
| 119 | +``` |
| 120 | +copy dbg\dpp-qk.bin E: |
| 121 | +``` |
| 122 | +NOTE: The above command assumes that the NUCLEO board enumerated as drive E:. Of course you need to adjust the command for your specific drive letter. |
| 123 | + |
| 124 | +Alternatively, if you use IDEs, such as KEIL-MDK or IAR EWARM, you can program the board from the IDE (e.g., by starting a debug session). |
| 125 | + |
| 126 | + |
| 127 | +# Tracing with QP/Spy |
| 128 | +When the board is flashed with the Spy build configuration, it produces the QP/Spy software tracing output to the built-in virtual COM port of the TivaC LauchPad board. The trace is binary rather than ASCII, and therefore requires a special host-based application called QSPY. |
| 129 | + |
| 130 | +> **NOTE** QSPY host application is available in the QTools collection. |
| 131 | +
|
| 132 | +To launch the QSPY host application: |
| 133 | +- open terminal window |
| 134 | +- type: |
| 135 | + |
| 136 | +``` |
| 137 | +qspy -c COM5 |
| 138 | +``` |
| 139 | + |
| 140 | +where "COM5" is an example virtual COM port enumerated by the board. You need to check the specific COM port number on your host computer using the Device Manager application, Ports (COM and LPT) section. |
| 141 | + |
| 142 | + |
| 143 | +The following screen shot shows a typical output from QSPY: |
| 144 | + |
| 145 | +<p align="center"> |
| 146 | +<img src="./qspy-output.png"/><br> |
| 147 | +<b>Typical QSPY output produced by the Spy build configuration</b> |
| 148 | +</p> |
| 149 | + |
0 commit comments