Um01014 Embos Cortexm Iar
Um01014 Embos Cortexm Iar
Real-Time
Operating System
Document: UM01014
Software version 4.34
Revision: 0
Date: March 27, 2017
www.segger.com
2
Disclaimer
Specifications written in this document are believed to be accurate, but are not guar-
anteed to be entirely free of error. The information in this manual is subject to
change for functional or performance improvements without notice. Please make sure
your manual is the latest edition. While the information herein is assumed to be
accurate, SEGGER Microcontroller GmbH & Co. KG (SEGGER) assumes no responsibil-
ity for any errors or omissions. SEGGER makes and you receive no warranties or con-
ditions, express, implied, statutory or in any communication with you. SEGGER
specifically disclaims any implied warranty of merchantability or fitness for a particu-
lar purpose.
Copyright notice
You may not extract portions of this manual or modify the PDF file in any way without
the prior written permission of SEGGER. The software described in this document is
furnished under a license and may only be used or copied in accordance with the
terms of such a license.
© 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG, Hilden / Germany
Trademarks
Names mentioned in this manual may be trademarks of their respective companies.
Brand and product names are trademarks or registered trademarks of their respec-
tive holders.
Contact address
SEGGER Microcontroller GmbH & Co. KG
In den Weiden 11
D-40721 Hilden
Germany
Tel.+49 2103-2878-0
Fax.+49 2103-2878-28
E-mail: [email protected]
Internet: http://www.segger.com
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
3
Manual versions
This manual describes the current software version. If any error occurs, inform us
and we will try to assist you as soon as possible.
Contact us for further information on topics or routines not yet specified.
Print date: March 27, 2017
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
4
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
5
Assumptions
This document assumes that you already have a solid knowledge of the following:
• The software tools used for building your application (assembler, linker, C com-
piler)
• The C programming language
• The target processor
• DOS command line
If you feel that your knowledge of C is not sufficient, we recommend The C Program-
ming Language by Kernighan and Richie (ISBN 0-13-1103628), which describes the
standard in C-programming and, in newer editions, also covers the ANSI C standard.
How to use this manual
This manual explains all the functions and macros that the product offers. It assumes
you have a working knowledge of the C language. Knowledge of assembly program-
ming is not required.
Typographic conventions for syntax
This manual uses the following typographic conventions:
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
6
emFile
File system
emFile is an embedded file system with
FAT12, FAT16 and FAT32 support. Vari-
ous Device drivers, e.g. for NAND and
NOR flashes, SD/MMC and Compact-
Flash cards, are available.
USB-Stack
USB device/host stack
A USB stack designed to work on any
embedded system with a USB control-
ler. Bulk communication and most stan-
dard device classes are supported.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
7
Table of Contents
1 Using embOS...................................................................................................................9
1.1 Installation ............................................................................................. 10
1.2 First steps .............................................................................................. 11
1.3 The example application OS_StartLEDBlink.c ............................................... 12
1.4 Stepping through the sample application .................................................... 13
3 Libraries .........................................................................................................................21
3.1 Naming conventions for prebuilt libraries .................................................... 22
5 Stacks ............................................................................................................................29
5.1 Task stack for Cortex-M............................................................................ 30
5.2 System stack for Cortex-M........................................................................ 30
5.3 Interrupt stack for Cortex-M...................................................................... 30
6 Interrupts........................................................................................................................31
6.1 What happens when an interrupt occurs? .................................................... 32
6.2 Defining interrupt handlers in C ................................................................. 32
6.3 Interrupt vector table............................................................................... 32
6.4 Interrupt-stack switching .......................................................................... 33
6.5 Zero latency interrupts ............................................................................. 33
6.5.1 Zero latency interrupts with Cortex-M ........................................................ 33
6.6 Interrupt priorities ................................................................................... 33
6.6.1 Interrupt priorities with Cortex-M cores ...................................................... 33
6.6.2 Priority of the embOS scheduler ................................................................ 34
6.6.3 Priority of the embOS system timer............................................................ 34
6.6.4 Priority of embOS software timers.............................................................. 34
6.6.5 Priority of application interrupts for Cortex M3 / M4 / M7 core........................ 34
6.7 Interrupt nesting ..................................................................................... 34
6.7.1 OS_EnterInterrupt() ................................................................................ 35
6.7.2 OS_EnterNestableInterrupt()..................................................................... 35
6.7.3 Required embOS system interrupt handlers................................................. 35
6.8 Interrupt handling with vectored interrupt controller..................................... 36
6.8.1 OS_ARM_EnableISR(): Enable specific interrupt........................................... 36
6.8.2 OS_ARM_DisableISR(): Disable specific interrupt ......................................... 37
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
8
7 CMSIS............................................................................................................................39
7.1 The generic CMSIS start project ................................................................ 40
7.2 Device specific files needed for embOS with CMSIS...................................... 40
7.3 Device specific functions/variables needed for embOS with CMSIS ................. 40
7.4 CMSIS generic functions needed for embOS with CMSIS............................... 41
7.5 Customizing the embOS CMSIS generic start project.................................... 41
7.6 Adding CMSIS to other embOS start projects .............................................. 42
7.6.1 Differences between embOS projects and CMSIS ......................................... 42
7.6.1.1 Different peripheral ID numbers ................................................................ 42
7.6.1.2 Different interrupt priority values .............................................................. 42
7.7 Interrupt and exception handling with CMSIS.............................................. 44
7.8 Enable and disable interrupts .................................................................... 44
7.9 Setting the Interrupt priority..................................................................... 44
11 Technical data..............................................................................................................63
11.1 Memory requirements.............................................................................. 64
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
9
Chapter 1
Using embOS
This chapter describes how to start with and use embOS. You should follow these
steps to become familiar with embOS.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
10 1 Using embOS
1.1 Installation
embOS is shipped as a zip-file in electronic form.
To install it, proceed as follows:
Extract the zip-file to any folder of your choice, preserving the directory structure of
this file. Keep all files in their respective sub directories. Make sure the files are not
read only after copying.
Assuming that you are using an IDE to develop your application, no further installa-
tion steps are required. You will find a lot of prepared sample start projects, which
you should use and modify to write your application. So follow the instructions of
section First steps.
You should do this even if you do not intend to use the IDE for your application devel-
opment to become familiar with embOS.
If you do not or do not want to work with the IDE, you should: Copy either all or only
the library-file that you need to your work-directory. The advantage is that when
switching to an updated version of embOS later in a project, you do not affect older
projects that use embOS, too. embOS does in no way rely on an IDE, it may be used
without the IDE using batch files or a make utility without any problem.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
11
For additional information you should open the ReadMe.txt file which is part of every
specific project. The ReadMe file describes the different configurations of the project
and gives additional information about specific hardware settings of the supported
eval boards, if required.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
12 1 Using embOS
/*********************************************************************
* SEGGER Microcontroller GmbH & Co. KG *
* The Embedded Experts *
**********************************************************************
File : OS_StartLEDBlink.c
Purpose : embOS sample program running two simple tasks, each toggling
a LED of the target hardware (as configured in BSP.c).
--------- END-OF-HEADER ----------------------------------------------
*/
#include "RTOS.h"
#include "BSP.h"
/*********************************************************************
*
* main()
*/
int main(void) {
OS_InitKern(); /* Initialize OS */
OS_InitHW(); /* Initialize Hardware for OS */
BSP_Init(); /* Initialize LED ports */
/* You need to create at least one task before calling OS_Start() */
OS_CREATETASK(&TCBHP, "HP Task", HPTask, 100, StackHP);
OS_CREATETASK(&TCBLP, "LP Task", LPTask, 50, StackLP);
OS_Start(); /* Start multitasking */
return 0;
}
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
13
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
14 1 Using embOS
Before you step into OS_Start(), you should set two breakpoints in the two tasks as
shown below.
As OS_Start() is part of the embOS library, you can step through it in disassembly
mode only.
Click GO, step over OS_Start(), or step into OS_Start() in disassembly mode until
you reach the highest priority task.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
15
If you continue stepping, you will arrive at the task that has lower priority:
Continue to step through the program, there is no other task ready for execution.
embOS will therefore start the idle-loop, which is an endless loop always executed if
there is nothing else to do (no task is ready, no interrupt routine or timer executing).
You will arrive there when you step into the OS_Delay() function in disassembly
mode. OS_Idle() is part of RTOSInit*.c. You may also set a breakpoint there before
stepping over the delay in LPTask.
If you set a breakpoint in one or both of our tasks, you will see that they continue
execution after the given delay.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
16 1 Using embOS
As can be seen by the value of embOS timer variable OS_Global.Time, shown in the
Watch window, HPTask continues operation after expiration of the 50 system tick
delay.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
17
Chapter 2
This chapter provides all information to set up your own embOS project.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
18 2 Build your own application
2.1 Introduction
To build your own application, you should always start with one of the supplied sam-
ple workspaces and projects. Therefore, select an embOS workspace as described in
chapter First steps and modify the project to fit your needs. Using an embOS start
project as starting point has the advantage that all necessary files are included and
all settings for the project are already done.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
19
If your CPU is currently not supported, examine all RTOSInit.c files in the CPU-spe-
cific subfolders and select one which almost fits your CPU. You may have to modify
OS_InitHW(), OS_COM_Init(), the interrupt service routines for embOS system timer
tick and communication to embOSView and the low level initialization.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
20 2 Build your own application
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
21
Chapter 3
Libraries
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
22 3 Libraries
Example
os6m_tl__dp.a is the library for a project using a Cortex-M0 core, thumb mode, little
endian mode with debug and profiling support.
os7m_tlv_dp.a is the library for a project using a Cortex-M4F core, thumb mode, lit-
tle endian mode and VFPv4 floating point unit with debug and profiling support.
Note:
The libraries for Cortex-M3 can also be used for Cortex-M4 and Cortex-M4F targets as
long as the VFP is not used in Cortex-M4F.
When VFPv4 is selected in the project options, the IAR startup code automatically
adds code to enable the VFP after reset.
When using your own startup code, please ensure the VPF is enabled or diasabled
according the project settings.
Using the VFP requires libraries with VFP support: os7m_tlv_xx.
All libraries can be used with IAR Embedded Workbench for ARM V6.x and V7.x.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
23
Chapter 4
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
24 4 CPU and compiler specifics
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
25
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
26 4 CPU and compiler specifics
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
27
4.3.1 OS_ExtendTaskContext_TLS()
Description
OS_ExtendTaskContext_TLS() may be called from a task to initialize and use
Thread-local storage.
Prototype
void OS_ExtendTaskContext_TLS (void);
Additional Information
OS_ExtendTaskContext_TLS() shall be the first function called from a task when TLS
should be used in the specific task.
The function must not be called multiple times from one task.
The thread-local storage is allocated on the heap. To ensure thread safe heap man-
agement, the thread safe system library functionality shall also be enabled when
using TLS.
Thread safe system library calls are automatically enabled when the source module
xmtx.c which is delivered with embOS in the CPU specific Setup folders is included in
the project.
The function is available in embOS for EWARM6 only.
Example
The following printout shows the sample application OS_ThreadLocalStorage.c,
which demonstrates the usage of task specific TLS in an application.
The sample program is included in the CPU specific Application folder, which contains
all sample applications for embOS.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
28 4 CPU and compiler specifics
/*********************************************************************
* SEGGER Microcontroller GmbH & Co. KG *
* The Embedded Experts *
**********************************************************************
File : OS_ThreadLocalStorage.c
Purpose : embOS sample application to demonstrate the usage of TLS.
TLS support is CPU and compiler specific and may not be
implemented in all OS ports.
-------- END-OF-HEADER ---------------------------------------------
*/
#include "RTOS.h"
#include <errno.h>
/*********************************************************************
*
* main()
*
*********************************************************************/
int main(void) {
errno = 1; /* Simulate an error */
OS_InitKern(); /* Initialize OS */
OS_InitHW(); /* Initialize Hardware for OS */
/* You need to create at least one task before calling OS_Start() */
OS_CREATETASK(&TCBHP, "HP Task", HPTask, 100, StackHP);
OS_CREATETASK(&TCBMP, "MP Task", MPTask, 70, StackMP);
OS_CREATETASK(&TCBLP, "LP Task", LPTask, 50, StackLP);
OS_Start(); /* Start multitasking */
return 0;
}
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
29
Chapter 5
Stacks
This chapter describes how embOS uses the different stacks of the Cortex-M CPU.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
30 5 Stacks
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
31
Chapter 6
Interrupts
The Cortex M core comes with a built-in vectored interrupt controller which supports
up to 240 separate interrupt sources. The real number of interrupt sources depends
on the specific target CPU.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
32 CHAPTER 6 Interrupts
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
33
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
34 CHAPTER 6 Interrupts
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
35
6.7.1 OS_EnterInterrupt()
Description
OS_EnterInterrupt(), disables nesting
Prototype
void OS_EnterInterrupt (void);
Additional Information
OS_EnterInterrupt() has to be used as prolog function, when the interrupt handler
should not be preempted by any other interrupt handler that runs on a priority below
the zero latency interrupt priority. An interrupt handler that starts with
OS_EnterInterrupt() has to end with the epilog function OS_LeaveInterrupt().
Example
Interrupt-routine that can not be preempted by other interrupts.
6.7.2 OS_EnterNestableInterrupt()
Description
OS_EnterNestableInterrupt(), enables nesting.
Prototype
void OS_EnterNestableInterrupt (void);
Additional Information
OS_EnterNestableInterrupt(), allow nesting. OS_EnterNestableInterrupt() may
be used as prolog function, when the interrupt handler may be preempted by any
other interrupt handler that runs on a higher interrupt priority. An interrupt handler
that starts with OS_EnterNestableInterrupt() has to end with the epilog function
OS_LeaveNestableInterrupt().
Example
Interrupt-routine that can be preempted by other interrupts.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
36 CHAPTER 6 Interrupts
Parameters
Parameter Description
Index of the interrupt source that should be enabled.
ISRIndex Note that the index counts from 0 for the first entry in the vec-
tor table.
Table 6.1: OS_ARM_EnableISR() parameter list
Additional Information
This function just enables the interrupt inside the interrupt controller. It does not
enable the interrupt of any peripherals. This has to be done elsewhere.
Note that the ISRIndex counts from 0 for the first entry in the vector table.
The first peripheral index therefore has the ISRIndex 16, because the first peripheral
interrupt vector is located after the 16 generic vectors in the vector table.
This differs from index values used with CMSIS.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
37
Parameters
Parameter Description
Index of the interrupt source that should be disabled.
ISRIndex Note that the index counts from 0 for the first entry in the vec-
tor table.
Table 6.2: OS_ARM_DisableISR() parameter list
Additional Information
This function just disables the interrupt in the interrupt controller. It does not disable
the interrupt of any peripherals. This has to be done elsewhere.
Note that the ISRIndex counts from 0 for the first entry in the vector table.
The first peripheral index therefore has the ISRIndex 16, because the first peripheral
interrupt vector is located after the 16 generic vectors in the vector table.
This differs from index values used with CMSIS.
Parameters
Parameter Description
Index of the interrupt source which should be modified.
ISRIndex Note that the index counts from 0 for the first entry in the vec-
tor table.
The priority which should be set for the specific interrupt.
Prio
Prio ranges from 0 (highest priority) to 255 (lowest priority)
Table 6.3: OS_ARM_ISRSetPrio() parameter list
Additional Information
This function sets the priority of an interrupt channel by programming the interrupt-
controller. Please refer to CPU-specific manuals about allowed priority levels.
Note that the ISRIndex counts from 0 for the first entry in the vector table.
The first peripheral index therefore has the ISRIndex 16, because the first peripheral
interrupt vector is located after the 16 generic vectors in the vector table.
This differs from index values used with CMSIS.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
38 CHAPTER 6 Interrupts
The priority value is independent of the chip-specific preemption levels. Any value
between 0 and 255 can be used, were 255 always is the lowest priority and 0 is the
highest priority.
The function can be called to set the priority for all interrupt sources, regardless of
whether embOS is used in the specified interrupt handler or not.
Note that interrupt handlers running on priorities from 127 or higher must not call
any embOS function.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
39
Chapter 7
CMSIS
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
40 7 CMSIS
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
41
tialization function SystemInit and the value of the core clock frequency which has to
be written into the SystemCoreClock variable during initialization or after calling Sys-
temCoreClockUpdate().
• SystemInit():The system init function is delivered by the vendor specific CMSIS
library and is normally called from the reset handler in the startup code. The sys-
tem init function has to initialize the core clock and has to write the CPU fre-
quency into the global variable SystemCoreClock.
• SystemCoreClock: Contains the current system core clock frequency and is ini-
tialized by the low level initialization function SystemInit() during startup.
embOS for CMSIS relies on the value in this variable to adjust its own timer and
all time related functions.
Any other files or functions delivered with the vendor specific CMSIS library may be
used by the application, but are not required for embOS.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
42 7 CMSIS
To run the generic CMSIS start project on a Cortex M0, you have to replace the
embOS libraries by libraries for Cortex M0 and have to add Cortex M0 specific vendor
files.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
43
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
44 7 CMSIS
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
45
Chapter 8
VFP support
Chapter 9
This chapter contains information about SEGGER Real Time Transfer and SEGGER
SystemView.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
48 9 RTT and SystemView
File Description
SEGGER_RTT.c Generic implementation of SEGGER RTT.
SEGGER_RTT.h Generic implementation header file.
SEGGER_RTT_Conf.h Generic RTT configuration file.
Generic printf() replacement to write formatted
SEGGER_RTT_printf.c
data via RTT.
Compiler-specific low-level functions for using
printf() via RTT.
SEGGER_RTT_Syscalls_*.c If this file is included in a project, RTT is used
for debug output. To use the standard out of your
IDE, exclude this file from build.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
49
File Description
Global type definitios required by
Global.h
SEGGER SystemView.
Generic types and utility function
SEGGER.h
header.
SEGGER_SYSVIEW.c Generic implementation of SEGGER RTT.
SEGGER_SYSVIEW.h Generic implementation include file.
SEGGER_SYSVIEW_Conf.h Generic configuration file.
SEGGER_SYSVIEW_ConfDefaults.h Generic default configuration file.
Target-specific configuration of
SEGGER_SYSVIEW_Config_embOS.c
SystemView with embOS.
Generic interface implementation for
SEGGER_SYSVIEW_embOS.c
SystemView with embOS.
Generic interface implementation header
SEGGER_SYSVIEW_embOS.h
file for SystemView with embOS.
SEGGER_SYSVIEW_Int.h Generic internal header file.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
50 9 RTT and SystemView
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
51
Chapter 10
This chapter gives a short overview about the embOS C-Spy plug-in for IAR Embed-
ded Workbench.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
52 10 embOS C-Spy plug-in
10.1 Overview
10.1.1 embOS C-Spy plug-in
SEGGER’s embOS C-Spy plug-in for IAR Embedded Workbench provides embOS-
awareness during debugging sessions. This enables you to inspect the state of sev-
eral embOS primitives such as the task list, resource semaphores, mailboxes, and
timers.
Since embOS version 3.62, you can check the general-purpose registers and inspect
the call stack of all available application tasks.
10.1.2 Requirements
To use the embOS C-Spy plug-in you need a version of IAR Embedded Workbench
installed and a debug target which uses embOS.
The following plug-ins are available and may be used with the listed versions of IAR’s
Embedded Workbench for ARM:
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
53
10.2 Installation
The installation procedure is very straightforward because it only requires you to
copy the contents of the embOS C-Spy plug-in package into the IAR CPU specific
plug-in folder for rtos plug-ins. The directory structure may look like this:
If not already delivered with the IAR Embedded Workbench IDE, create a directory
embOS below the CPU specific plugin\rtos\ folder and copy the files from the embOS
folder which comes with the plug-in into that folder in your IAR installation directory.
Then restart the IAR Embedded Workbench IDE.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
54 10 embOS C-Spy plug-in
10.3 Configuration
By default, the embOS C-Spy plug-in is not loaded during debugging. For each
project configuration you have to explicitly enable the plugin in the debugger section
of the project options:
The embOS C-Spy plug-in is now available in debugging sessions and may be
accessed from the main menu.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
55
From the menu you may activate the individual windows that provide embOS related
information. The sections below describe these individual windows. The amount of
information available depends on the embOS build used during debugging. If a cer-
tain part is not available, the respective menu item is either greyed out or the win-
dow column shows a N/A.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
56 10 embOS C-Spy plug-in
10.4.1 Tasks
The Task List window lists all embOS tasks. It retrieves its information directly from
the embOS task list. The green arrow points to the running task, which is the task
currently executing. If no task is executing, the CPU is executing the Idle-loop. In
this case, the green arrow is in the bottom row of the window, labeled “Idle”.
The bottom row of the task list window is always labeled “Idle”. It does not actually
represent a task, but the Idle loop, which is executed if no task is ready for execu-
tion.
Column Description
* A green arrow points to the running task.
Prio Priority of the task.
Id The task control block address that uniquely identifies a task.
Name If available, the task name is shown here.
Status The task status as a short text.
If a task is delayed, this column shows the time remaining until the
Timeout
delay expires and in parenthesis the time of expiration.
If available, this column shows the amount of used stack space, and
Stack Info the available stack space, as well as the value of the current stack
bottom pointer.
Run count The number of task activations.
If round robin scheduling is available, this column shows the number
Time slice
of remaining time slices and the number of time slice reloads.
Events The event mask of a task.
Table 10.2: Task list window items
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
57
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
58 10 embOS C-Spy plug-in
Interrupted tasks
Tasks which have been interrupted and preempted, typically by a task with higher
priority becoming ready. In this case, the OS saved all registers, including the
scratch registers (in case of ARM R0-R3, R12). The Register window shows the val-
ues of all registers, including the scratch registers.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
59
10.4.2 Mailboxes
A mailbox is a buffer that is managed by the real-time operating system. The buffer
behaves like a normal buffer; you can put something (called a message) in and
retrieve it later. This window shows the mailboxes and provides information about the
number of messages, waiting tasks etc.
Column Description
Id The mailbox address.
The number of messages in a mailbox and the maximum number of
Messages
messages as mailbox can hold.
Message size The size of an individual message in bytes.
pBuffer The message buffer address.
The list of tasks that are waiting for a mailbox, that is their address
Waiting tasks
and name.
Table 10.3: Mailboxes window items
10.4.3 Timers
A software timer is an object that calls a user-specified routine after a specified
delay. This window provides information about active software timers.
Column Description
Id The timer’s address.
Hook The function (address and name) that is called after the timeout.
The time delay and the point in time, when the timer finishes wait-
Time
ing.
Period The time period the timer runs.
Active Shows whether the timer is active or not.
Table 10.4: Timers window items
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
60 10 embOS C-Spy plug-in
Column Description
Id The resource semaphore address.
Owner The address and name of the owner task.
Use counter Counts the number of semaphore uses.
Lists the tasks (address and name) that are waiting at the sema-
Waiting tasks
phore.
Table 10.5: Resource Semaphores window items
10.4.6 Settings
To be safe, the embOS C-Spy plug-in imposes certain limits on the amount of infor-
mation retrieved from the target, to avoid endless requests in case of false values in
the target memory. This dialog box allows you to tweak these limits in a certain
range, for example if your task names are no longer than 32 characters you may set
the Maximum string length to 32, or if they are longer than the default you may
increase that value.
After changing settings and clicking the OK button, your changes are applied imme-
diately and should become noticeable after the next window update, for example
when hitting the next breakpoint. However, the settings are restored to their default
values on plug-in reload.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
61
10.4.7 About
Finally, the About dialog box contains the embOS C-Spy plug-in version number and
the date of compilation.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
62 10 embOS C-Spy plug-in
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
63
Chapter 11
Technical data
This chapter lists technical data of embOS used with Cortex-M CPUs.
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
64 11 Technical data
Software timer 20
Resource semaphore 16
Counting semaphore 8
Mailbox 24
Queue 36
Task event 0
Event object 12
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
65
Index
Symbols
__NVIC_PRIO_BITS ....................... 42, 44
C
CMSIS ................................................39
C-Spy plug-in ......................................52
I
Installation .........................................10
interrupt handlers ................................32
Interrupt nesting .................................34
Interrupt priorities ...............................33
Interrupt stack ....................................30
Interrupt vector table ...........................32
Interrupts ...........................................31
Interrupt-stack ....................................33
M
Memory requirements ..........................64
O
OS_ExtendTaskContext_TLS() ...............27
OS_ExtendTaskContext_VFP() ...............46
OS_ThreadLocalStorage.c .....................27
S
Stacks ................................................29
Syntax, conventions used ...................... 5
System stack ......................................30
SystemCoreClock .................................41
SystemInit() .......................................41
T
Task stack ..........................................30
Thread Local Storage ...........................27
TLS ....................................................27
V
Vector Floating Point support .................46
VFPv4 ................................................46
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG
66
X
xmtx.c .......................................... 25–27
xmtx2.c ........................................ 25–26
embOS for Cortex-M and IAR © 2009 - 2017 SEGGER Microcontroller GmbH & Co. KG