SEOS (Simple Embedded Operating System)
SEOS is a small and simple embedded RTOS. It is loosely based on
the ADEOS operating system described in "Programming Embedded
Systems in C and C++" by Michael Barr (see
Recomended Books). It runs on the Atmel AVR ATmega
processors. It was developed on the ATmega16 but it should
run on any of the ATmega processors. In general it should be
relatively easy to modify SEOS to work with other architectures
-- most changes will need to be made to the context switching
code. The main features of SEOS are a priority based cooperative
multitasking scheduler, critical sections, serial port
communications, and timer management. However, what's probably
the best thing about SEOS is that it is very simple and easy
to understand and provides a good starting point for more advanced
applications. NOTE: SEOS has not been rigorously tested and any
applications that use it should be carefully debugged.
Development Environment
SEOS was developed using the WinAVR (20030424) compiler package.
WinAVR is a free port for Windows of the avr-gcc cross compiler.
The hardware used is a ATmega16 running on a STK500 development
board made by Atmel. AVRStudio 4.07, which is freely available
from Atmel, was used to program the board and run simulations.
WinAVR, along with a lot of other useful AVR stuff, is available
at www.avrfreaks.net.
Memory Usage
The minimum amount of memory required to run SEOS depends on the
number of tasks added. Realistically 1-Kbyte of SRAM would be a
good minimum to use. The state for each task requires 43 bytes.
This state includes a 32-byte array used to save all the
registers. To minimize the memory usage the context switch
code can be modified to only save the minimum required registers
-- the registers that must be saved is compiler specific.
Each task must also have a stack size that is at least 4 bytes +
stack size of the interrupt with the greatest stack size + any
additional stack needed by the task for local variables and
function calls. The stack for each task, as well as the state
for the task, is stored on the heap. The size of each task's
stack is set when the task is added. When accounting for
the stack size of interrupt routines it is important to note
that several registers need to be saved on the stack. For WinAVR
(avr-gcc for Windows) the minimum stack size for an interrupt
is approx 17 bytes -- return pointer + 15 saved registers.
Therefore, the total minimum stack size for a task is 4 + 17 +
greatest interrupt stack size + task specific stack data bytes.
To be on the safe side a few additional bytes should be added to
the task's stack. Also, SEOS uses about 10 bytes of the system
stack space when starting up. NOTE: These memory figures are
approximations and have not been carefully tested -- when
debugging, stack overflows should always be checked for.
SEOS has its own dynamic memory allocation functions. These
functions can be found in the alloc.c module. This module
creates a static byte array and allocates pieces of it when
needed.
Coding Conventions
The naming and style conventions used for SEOS are primarily
based on a handout written by Prof. David Stewart (see
Handout 3).
SEOS Code Download
Click here to download SEOS source code.
Please click on Feedback to send any questions/comments or bugs.
Code For Tiny Processors
These modules are used for processors that are too small to
support a RTOS, such as the ATtiny processors. Two C modules are
currently included: sleep.c and swtx.c. The processor used when
developing these is the ATtiny26, which has 128 Bytes of SRAM.
The sleep module simply implements a sleep() function that
blocks (busy waits) for a specified number of milliseconds.
Timer/Counter0 is used to keep track of the sleep time. The swtx
module is a software implementation of a UART transmitter. It
can be configured to use any I/O pin. Timer/Counter1 is used
to generate the baud rate for the swtx module.
TINY Code Download
Click here to download TINY source code.
Please click on Feedback to send any questions/comments or bugs.
Recomended Books:
Programming Embedded Systems in C and C++
By Michael Barr
Published by O'Reilly & Associates, Inc.
www.oreilly.com/catalog/embsys/
Designing Embedded Hardware
By John Catsoulis
Published by O'Reilly & Associates, Inc.
www.oreilly.com/catalog/dbhardware/
Related Links:
www.avrfreaks.net
www.atmel.com
www.oreilly.com
|
|