Specifications written in this document are believed to be accurate, but are not guaranteed 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 (SEGGER) assumes no responsibility for any errors or omissions. SEGGER makes and you receive no
warranties or conditions, express, implied, statutory or in any communication with you. SEGGER
specifically disclaims any implied warranty of merchantability or fitness for a particular 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.
This manual describes the current software version. If you find an error in the manual or a
problem in the software, please inform us and we will try to assist you as soon as possible.
Contact us for further information on topics or functions that are not yet documented.
Print date: March 1, 2021
Software RevisionDateByDescription
5.10.0.01210301MM
5.10.0.00200617TS/MM
5.061190930MC
5.060190514MM
5.02a0180727MM
5.000180522MM
4.400180104MC
4.380170928MC
4.360170721MC
4.340170327TS
4.300161213MC
4.260161027RH
4.220160531MC
4.160160122MC
4.140151222MC
4.12a0150917TS
4.100150505TS
4.06b0150330TS
4.06a0150317TS
4.04a0150109SC
4.02a0140918TS
4.020140819TS
4.000140606TS
3.900140228AW
3.88g0131104TS
3.88c0130813TS
3.88b0130528AW/TS
3.86n0121210AW
3.86l0121126TS
3.86g0120806AW
3.86f0120726AW
Added missing chapter “CPU and compiler specifics”.
Chapter “Libraries” updated.
Chapter “CPU and compiler specifics -> IAR C-Spy stack check warning”
added.
Chapter “Libraries” updated.
New software version.
New software version.
New software version.
New software version.
New software version.
New software version.
Chapter “Compiler specifics” updated.
New software version.
Chapters “Using embOS” and “embOS C-Spy Plugin” updated.
Chapters “VFP support”, “CPU and compiler specifics”, and “embOS CSpy Plugin” updated.
New software version.
New software version.
New software version.
Chapter “Compiler specifics” updated.
New software version.
Typos corrected.
New software version.
New generic embOS sources V4.04a.
New generic embOS sources V4.02a.
New generic embOS sources V4.02.
New generic embOS sources V4.00.
New generic embOS sources V3.90.
Updated start project for EWARM V7.10.
New generic embOS sources V3.88g.
New generic embOS sources V3.88c.
New generic embOS sources V3.88b.
Chapter 4, “Thread safe system libraries with IAR compiler V6.4 or newer” corrected. One required linker parameter was missing in previous description.
New generic embOS sources V3.86n.
Chapter 4, “Thread safe system libraries with IAR compiler V6.4 or newer” added to describe the procedure to activate thread safe library support with newer IAR compiler.
Software: New embOS sources V3.86i.
Software: New embOS sources V3.86g.
Software: New embOS sources V3.86f.
Task events are 32bits wide for Cortex-M.
Software: New embOS sources V3.86e.
Modified hard fault handler added to RTOSInit.
Software: New embOS sources V3.86d.
OS_ExtendTaskContext_TLS_VFP() corrected.
Software: Scheduler for Cortex-M4 with VFP corrected.
Chapter 4: New functions to save and restore VFP context of Cortex-M4
in ISR handler:
OS_VFP_Save()
OS_VFP_Restore()
Software version updated.
Software: New scheduler uses main stack for OS_Idle().
Chapter 5: Stacks, system stack descripton updated.
New Chapter 6.8.4 and 6.8.5: Interrupt peripheral identifier and priority
values used with embOS described more in detail.
Chapter 7: Interrupt controller setup using CMSIS described more in detail. New chapter 7.7.1 describes differences between embOS functions
and CMSIS functions.
Chapter 3.2.1: New libraries with VFPv4 support added.
Chapter 4.3, 4.4: Support for VFPv4 added:
This document assumes that you already have a solid knowledge of the following:
•The software tools used for building your application (assembler, linker, C compiler).
•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 Programming Lan-guage 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 programming is not required.
Typographic conventions for syntax
This manual uses the following typographic conventions:
StyleUsed for
BodyBody text.
Keyword
ParameterParameters in API functions.
SampleSample code in program examples.
Sample commentComments in program examples.
Reference
GUIElementButtons, dialog boxes, menu names, menu commands.
EmphasisVery important sections.
Text that you enter at the command prompt or that appears on
the display (that is system functions, file- or pathnames).
Reference to chapters, sections, tables and figures or other documents.
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 installation
steps are required. You will find many prepared sample start projects, which you should
use and modify to write your application. So follow the instructions of section First Steps
on page 11.
You should do this even if you do not intend to use the IDE for your application development
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.
After installation of embOS you can create your first multitasking application. You have
received several ready to go sample start workspaces and projects and every other files
needed in the subfolder Start. It is a good idea to use one of them as a starting point for
all of your applications. The subfolder BoardSupport contains the workspaces and projects
which are located in manufacturer- and CPU-specific subfolders.
To start with, you may use any project from BoardSupport subfolder.
To get your new application running, you should proceed as follows:
•Create a work directory for your application, for example c:\work.
•Copy the whole folder Start which is part of your embOS distribution into your work
directory.
•Clear the read-only attribute of all files in the new Start folder.
•Open one sample workspace/project in
Start\BoardSupport\<DeviceManufacturer>\<CPU> with your IDE (for example, by
double clicking it).
•Build the project. It should be built without any error or warning messages.
After generating the project of your choice, the screen should look like this:
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.
12CHAPTER 1The example application OS_StartLEDBlink.c
1.3 The example application OS_StartLEDBlink.c
The following is a printout of the example application OS_StartLEDBlink.c. It is a good
starting point for your application. (Note that the file actually shipped with your port of
embOS may look slightly different from this one.)
What happens is easy to see:
After initialization of embOS; two tasks are created and started. The two tasks are activated
and execute until they run into the delay, then suspend for the specified time and continue
execution.
-------------------------- END-OF-HEADER ----------------------------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).
*/
#include"RTOS.h"
#include"BSP.h"
static OS_STACKPTR int StackHP[128], StackLP[128]; // Task stacks
static OS_TASK TCBHP, TCBLP; // Task control blocks
staticvoid HPTask(void) {
while (1) {
BSP_ToggleLED(0);
OS_TASK_Delay(50);
}
}
staticvoid LPTask(void) {
while (1) {
BSP_ToggleLED(1);
OS_TASK_Delay(200);
}
}
13CHAPTER 1Stepping through the sample application
1.4 Stepping through the sample application
When starting the debugger, you will see the main() function (see example screen shot
below). The main() function appears as long as project option Run to main is selected,
which it is enabled by default. Now you can step through the program.
OS_Init() is part of the embOS library and written in assembler; you can there fore only
step into it in disassembly mode. It initializes the relevant OS variables.
OS_InitHW() is part of RTOSInit.c and therefore part of your application. Its primary
purpose is to initialize the hardware required to generate the system tick interrupt for
embOS. Step through it to see what is done.
OS_Start() should be the last line in main(), because it starts multitasking and does not
return.
15CHAPTER 1Stepping through the sample application
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_TASK_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().
16CHAPTER 1Stepping through the sample application
If you set a breakpoint in one or both of our tasks, you will see that they continue execution
after the given delay.
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.