-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
136 changed files
with
44,469 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
> **NOTE** | ||
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. | ||
|
||
# DPP on NUCLEO-C031C6 | ||
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+). | ||
|
||
<p align="center"> | ||
<img src="./stm32-nucleo-c031c6.jpg"/><br> | ||
<b>STM32 NUCLEO-C031C6</b> | ||
</p> | ||
|
||
> **NOTE** | ||
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). | ||
|
||
<p align="center"> | ||
<img src="../qp_arm-cm.jpg"/> | ||
</p> | ||
|
||
## Features Demonstrated | ||
- multiple cooperating active objects | ||
- immutable (const) events | ||
- mutable (dynamic) events | ||
- time events | ||
- direct event posting | ||
- publish-subscribe event delivery | ||
- cooperative QV kernel | ||
+ with ARM-KEIL toolchain | ||
+ with GNU-ARM toolchain | ||
+ with IAR-ARM toolchain | ||
- preemptive run-to-completion QK kernel | ||
+ with ARM-KEIL toolchain | ||
+ with GNU-ARM toolchain | ||
+ with IAR-ARM toolchain | ||
- preemptive dual-mode QXK kernel | ||
+ with ARM-KEIL toolchain | ||
+ with GNU-ARM toolchain | ||
+ with IAR-ARM toolchain | ||
|
||
## Build Configurations | ||
- Debug | ||
- Release | ||
- Spy - software tracing with the built-in virtual COM port | ||
|
||
# Code Organization | ||
``` | ||
examples\arm-cm\dpp_nucleo-c031c6 | ||
| | ||
+---qk // preemptive QK kernel | ||
| +---gnu // GNU-ARM toolchain | ||
| | \---targetConfigs | ||
| | Makefile // Makefile for GNU-ARM | ||
| +---armclang // ARM/KEIL toolchain with Compiler 6 (ARM/CLANG) | ||
| | dpp-qk.uvprojx // uVision project | ||
| \---iar // IAR EWARM | ||
| dpp-qk.eww // IAR EW-ARM workspace | ||
| | ||
\---qv // cooperative QK kernel | ||
| +---gnu // GNU-ARM toolchain | ||
| | \---targetConfigs | ||
| | Makefile // Makefile for GNU-ARM | ||
| +---armclang // ARM/KEIL toolchain with Compiler 6 (ARM/CLANG) | ||
| | dpp-qv.uvprojx // uVision project | ||
| \---iar // IAR EWARM | ||
| dpp-qv.eww // IAR EW-ARM workspace | ||
| | ||
+---qxk // preemptive, dual-mode QXK kernel | ||
| +---gnu // GNU-ARM toolchain | ||
| | \---targetConfigs | ||
| | Makefile // Makefile for GNU-ARM | ||
| +---armclang // ARM/KEIL toolchain with Compiler 6 (ARM/CLANG) | ||
| | dpp-qxk.uvprojx // uVision project | ||
| \---iar // IAR EWARM | ||
| dpp-qxk.eww // IAR EW-ARM workspace | ||
| | ||
``` | ||
|
||
# Building the example | ||
|
||
### GNU/ARM | ||
- open terminal window | ||
- 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`) | ||
- to build the default Debug configuration, type: | ||
|
||
``` | ||
make | ||
``` | ||
|
||
> **NOTE** | ||
The `make` utility for Windows is provided in the QTools collection for Windows. | ||
|
||
- to build the Release configuration, type: | ||
|
||
``` | ||
make CONF=rel | ||
``` | ||
|
||
- to build the Spy configuration, type: | ||
|
||
``` | ||
make CONF=spy | ||
``` | ||
|
||
|
||
### ARM/KEIL MDK | ||
- Open the provided KEIL uVision project (either `dpp-qk.uvprojx`, `dpp-qv.uvprojx`, or `dpp-qxk.uvprojx`) | ||
in Keil uVision IDE. Build/Debug/Download to the board from the IDE. | ||
- Change the build configuration in the "Project Target" drop-down menu. | ||
|
||
|
||
### IAR EWARM | ||
- Open the provided IAR EWARM workspace (either `dpp-qk.eww`, `dpp-qv.eww`, or `dpp-qxk.eww`) | ||
in IAR EWARM IDE. Build/Debug/Download to the board from the IDE. | ||
- Change the build configuration in the "Project Configuration" drop-down menu. | ||
|
||
|
||
# Uploading the Binary to the Board | ||
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: | ||
|
||
``` | ||
copy dbg\dpp-qk.bin E: | ||
``` | ||
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. | ||
|
||
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). | ||
|
||
|
||
# Tracing with QP/Spy | ||
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. | ||
|
||
> **NOTE** QSPY host application is available in the QTools collection. | ||
To launch the QSPY host application: | ||
- open terminal window | ||
- type: | ||
|
||
``` | ||
qspy -c COM5 | ||
``` | ||
|
||
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. | ||
|
||
|
||
The following screen shot shows a typical output from QSPY: | ||
|
||
<p align="center"> | ||
<img src="./qspy-output.png"/><br> | ||
<b>Typical QSPY output produced by the Spy build configuration</b> | ||
</p> | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
About this Example | ||
================== | ||
This example demonstrates how to use the uVision IDE together with | ||
the MDK-ARM toolchain. | ||
|
||
*** | ||
NOTE: This example requires installing the following Software Pack | ||
in the Keil uVision: Keil::STM32C0xx_DFP. | ||
*** | ||
|
||
uVision Project File | ||
==================== | ||
The MDK-ARM uVision project file provided with this example uses | ||
relative paths to the QP/C framework location (includes, port, and | ||
libraries. These relative paths must be modified when the project | ||
is moved to different relative location. | ||
|
||
|
||
Adjusting Stack and Heap Sizes | ||
============================== | ||
The stack and heap sizes are determined in this project by the | ||
command-line options for the ARM assembler (see the Asm tab in | ||
the "Options for Target" dialog box in uVision). Specifically, | ||
you should define symbols: Stack_Size=xxx Heap_Size=yyy, where | ||
xxx represents a numerical value of stack size and yyy the | ||
numerical value of the heap size. | ||
|
||
|
||
Selecting QK Exception | ||
====================== | ||
The QK kernel needs a dedicated exception to return to the thread | ||
context after preemption. The default is to use the NMI exception | ||
for that purpose. However, in case NMI is needed for some other | ||
purpose, the QK port allows you to select a any, otherwise unused | ||
IRQ for that purpose. To choose a given IRQ, you need to define | ||
the macros QK_USE_IRQ_NUM and QK_USE_IRQ_HANDLER. These macros can | ||
be provided on the command-line to the compiler. | ||
|
||
For example, (see the vector table), you can define the QK IRQ | ||
as follows: | ||
|
||
QK_USE_IRQ_HANDLER=Reserved31_IRQHandler | ||
QK_USE_IRQ_NUM=31 | ||
|
||
|
||
Startup Code | ||
============ | ||
The startup code for the STM32C0xx MCU used in this project is | ||
located in the "3rd_party" folder in the following location: | ||
|
||
3rd_party\nucleo-c031c6\arm\startup_stm32c031xx.s | ||
|
||
The file startup_stm32c031xx.s provides a template of the recommended | ||
startup for QP applications and should be easily customizable for other | ||
ARM Cortex-M microcontrollers. | ||
|
||
The startup file typically does not need to be modified or adapted for | ||
applications. It calls the assert_failed() function, which must be | ||
defined in the application to customize it for the application-specific | ||
error-handling policy. | ||
|
||
|
||
Adjusting the CPU Clock Speed | ||
============================= | ||
The current setting is to run at 12MHz from the MSI (internal oscillator), | ||
but the CPU clock speed can be modified. | ||
|
||
*** | ||
NOTE: | ||
The NUCLEO boards have a wide range of possible clock selections, depending | ||
on the solder bridge configuration. Please see Chapter 5.7 "OSC clock" in | ||
the STM32 NUCLEO Boards User Manual (ST document UM1724) for more information. | ||
*** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
; ************************************************************* | ||
; *** Scatter-Loading Description File generated by uVision *** | ||
; | ||
; Adapted by Quantum Leaps: | ||
; added STACK as the first section in RW_STACK | ||
; ************************************************************* | ||
|
||
LR_IROM1 0x08000000 0x00080000 { ; load region size_region | ||
ER_IROM1 0x08000000 0x00080000 { ; load address = execution address | ||
*.o (RESET, +First) | ||
*(InRoot$$Sections) | ||
.ANY (+RO) | ||
.ANY (+XO) | ||
} | ||
RW_IRAM1 0x20000000 0x00040000 { ; RW data | ||
.ANY (+RW +ZI) | ||
} | ||
|
||
RW_STACK 0x28000000 { ; STACK area | ||
* (STACK, +First) | ||
} | ||
RW_IRAM2 +0 (0x00004000 - 2048) { | ||
.ANY (+RW +ZI) | ||
} | ||
} | ||
|
Oops, something went wrong.