Circuit Lake

Electronic Project and Circuit Collection

TinyRealTime, Small Real Time Kernel for AVR

06/27/2012 Category: AVR, Miscellaneous

Real-time kernel (RTK) is useful to run several task or protocol on one CPU. Since only one task at a time can be executed by MCU, RTK used to make each task think it owns the whole machine. RTK will handle which task has to be saved while other tasks execute.

Small Real Time Kernel for AVR

TinyRealTime is a very small and fairly fast real-time kernel for the atmega644 written by Dan Henriksson and Anton Cervin. This kernel has several characteristics which make it interesting:

  • Several tasks can be created, limited by memory space. Practically, probably a maximum of a dozen or so tasks can be run on a Mega644/1284.
  • Each task has a release time and deadline which determines when it executes. The scheduling algorithm is Earliest Deadline First (EDF).
  • A task can be put to sleep for a period, thereby freeing the MCU for another task.
  • There are semaphores to protect shared resources (e.g. memory, or the UART) which are used by more than one task.
  • TRT was written in GCC for the Mega8. Porting to the Mega644 was easy (rename timer registers, add one byte to the stack). It could run on any Atmel AVR processor with a 16-bit timer and sufficient RAM.