OSA / RTOS — Quick Intro — Part 1/3

Real-Time Operating System for Microchip PIC-controllers

J3
Jungletronics
4 min readAug 18, 2017

--

I’ve just stumbled across OSA.

Real-Time Operating System (RTOS) for Microchip PIC, Atmel AVR 8-bit controllers, and for STMicroelectronics.

Has anyone out there used this?

I have been using OSA/RTOS a lot!

In this series of three posts I’ll give you a hint on how to run OSA/RTOS on a PIC18 Family using MikroC Pro For Pic from Microchip.

What is OSA?

1- OSA is a cooperative multi-tasking, non-preemptive, a priority based OS (RTOS) for Microchip PIC-controllers PIC10, PIC12, PIC16, PIC18, PIC24, dsPIC, for Atmel AVR 8-bit controllers, and for STMicroelectronics STM8;

2- It works very well and is superior to the conventional superloop and state machine approaches traditionally used in multi-tasking applications;

3- Its very small footprint (being co-operative, it does not need a separate stack for each task as would a preemptive RTOS) allows it to run comfortably in devices such as a PIC12 (or AVRTiny) but also works well with PIC18’s, PIC24’s and dsPIC33's;

4- It supports many of the features of full-blown RTOS’s such as semaphores (binary and counting), events, messages and data queues, mutexes, timers, etc;

5- It does come with full source code — in both C and ASM where applicable (for each supported development platform);

6- It is a great way to get you feet wet before looking into products such as Avix-RT, Q-Kernel, uC/OS and the like;

7- RTOS allows the programmer to focus on problem-oriented tasks (algorithmic, mathematical etc.) and not have to worry about secondary tasks. All secondary tasks are performed by OSA’s kernel;

8- Secondary tasks?
— switching between parallel processes (e.g. keyboard scanning, output data to LCD, switching relays);

— checking timeouts, counting delays;

— finding the ready task with the highest priority and executing it;

— data exchange between different tasks using semaphores, messages, queues, flags, etc;

— task management;

— queue management;

— memory management;

— critical session control function;

— A resource kernel for guaranteed and enforced timing behavior;

It enforces data coherency;

— organize driver access, critical resources and the like;

— you’ll name it…I’m into OSA for short time:-b

9- and last but not least, being FREE makes an excellent introduction to the world of RTOS’s and multi-tasking.

Main concepts

Task

A task in OSA is a C-function. This function must contain an infinite loop which has inside it at least one service that switches task context. A simple task can look like this:

Scheduler

Enforces scheduling processes for serve the Tasks.

Types of schedule policies: FIFO and Round Robin

FIFO

Task that is using the scheduling policy in FIFO mode will only be interrupted if a task with a higher priority is ready for execution.

Tasks of the same priority will be blocked until the running task releases the CPU.

Round Robin

The Round Robin scheduler is similar to FIFO, but differs in the following aspect. Each task in the Round Robin scheduling policy has a certain run time, this time is called Time-Slice.

It’s a template:

The default time-slice value may be ten times the value of the Timer interrupt period.

Services :

Here is a General framework of the program:

But, anyway, here we go with a working program using MikroC Pro For PIC program!

I confess this is the my first adventure with operating systems, even more novelty in embedded systems and I’m loving it!

But this is subject for the next post. Bye for now!

10 Step-by-Step is coming soon:-)

J3 is signing off…for now…

See you around!

References:

PART 1PART 2 — PART 3

OSA/RTO-OFFICIAL SITE
Wizard to configure OSA projects (v1.9)
microgenios.com.br — Thinking about signing up for a Crash Course about OSA/RTOS, Embedded Systems Training? Check it out! — Thanks to Fernando Simplício and Gabriel Rosa for awesome Microcontroller coaching : Curso de Formação de Especialistas em Microcontroladores PIC.

--

--

J3
Jungletronics

Hi, Guys o/ I am J3! I am just a hobby-dev, playing around with Python, Django, Ruby, Rails, Lego, Arduino, Raspy, PIC, AI… Welcome! Join us!