Psoc-An2046
AN2046
Real-Time Operation System for PSoC MCUs
By: Edward Nova
Associated Project: Yes
Associated Part Family: CY8C25xxx, CY8C26xxx
Summary
This Application Note is a demonstration of a Real-Time Operation System (RTOS) for PSoC
microcontrollers. This can be used for variety of applications such as control systems or automotive
industries.
Introduction
PSoCmicrocontrollers have versatile interrupt
capabilities, which is what modern embedded
applications require.
It was considered that the implementation of a
RTOS’ Kernel, using the Rate Monotonic
Scheduling (RMS) with task blocking method is
best suited for PSoC. We will show how this
Real-Time Multi-tasking Kernel provides means
to run a number of tasks at a specific time
interval by usingPeriodic Time Slot method. In
this implementation, the Periodic Time Slots do
not block each other. The task blocking is
possible only by using the Interrupt services.
The implementation is very simple, runs very fast
and does not consume valuable CPU time and
memory. This framework also can be extended to
accommodate much more complex scheduling
methods.
This project has been developedwith the PSoC
Designer Version 3.10 Build 240.This Application
will run with Pod 28 Rev D. or E.
To illustrate the Multithread feature of the RTOS,
eight LEDs on the Pod (Or Pup) are being
toggled. Each task has an associated LED. The
LED will blink according to its task time slot.
Every time slot is twice as long as the previous
one.
Using this RTOS will enable you to create your
projectin much shorter time. At the same time,
the structure of RTOS is helpful to organize your
program modules.
10/21/2002
There are many variations of RTOSs. The one
described in this Application Note is designed to
be very fast and simple to implement. As I will
demonstrate, this RTOS does not take too many
resources from PSoC. There are number of other
advantages that will be discussedin more details
later.
Real-Time Operating System
A typical Operating System includes some or all
of the following functions:
Hardware Interface
Memory Management
Task Scheduling
Interrupt Handling
File Management
Device Drivers
Networking
In Real-Time Systems a right answer at the
wrong time is a wrong answer. In time-critical
systems, operating system guarantees that all
thecritical sections of the program are processed
in a timely manner and will meet their deadlines.
Embedded System Modeling
Depending on each application, the designer
needs to choose a proper microcontroller. The
CPU speed, memory space and the number of
input and output are some of the features that
must be considered when choosing a
microcontroller. On the other hand, designers
also needto choose how to handle the software
requirements.
Revision A
-1-
AN2046
There are number of ways to model an
embedded system, these include:
Sequential Processing
State Machines
Multitasking
Sequential Processing
In Sequential Processing, tasks are handled one
at a time and CPU is allocating all its time and
other resources to this specific task. Traditional
flowcharts arequite capable of illustrating these
systems. Sequential Processing can be used in
sections of a complex system, a small size
system or an application that does not deal with
multiple events or external interrupts.
State Machines
State Machines are very useful and can simplify
systems that have limited number of states. The
transaction rules are not complicated. For
example, scanning akeyboard or modeling of an
elevator can be implemented with a simple State
Machines.
Multitasking
A task is a small program section to do a job. It is
a basic unit of resource allocation. Tasks are
competing for CPU time, memory space or other
resources. A complex problem can be divided to
a number of smaller and simpler tasks. A big task
also can be divided into several small time slots....
Regístrate para leer el documento completo.