Available Languages?:

OSA : Introduction

What is OSA?

OSA is a cooperative multitasking real-time operating system (RTOS) for Microchip PIC-controllers PIC10, PIC12, PIC16, PIC18, PIC24, dsPIC, for Atmel AVR 8-bit controllers, and for STMicroelectronics STM8.

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:

  • 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 etc.

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:

void SimpleTask (void)
    for (;;)        // Infinite loop
        OS_Yield(); // Unconditional context switching



PIC10/12 PIC16/12 PIC16F1xxx PIC18 PIC24/dsPIC
Microchip C
mikroC PRO


AVR 8-bit
Code Vision AVR





  • You should use the services OS_EnterInt (saves FSR) and OS_LeaveInt (restores saved FSR) when entering and leaving an interrupt routine. OS_EnterInt must be placed at the beginning of the ISR function, and OS_LeaveInt at the end.
void interrupt int_routine (void)
    char var1, var2;
    int var3;
    // After definition of local variables we need to save FSR:
    /* Interrupt flags checking */
    // At the end of ISR we need to restore FSR:

These services save and restore the FSR value (FSR0 for htpicc18), since HT-PICC sometimes does not do it.

Microchip C18

  • You can't use procedural abstraction optimization
  • You can't use Stack Model: Multi-bank

Microchip C30

  • You can't use procedural abstraction optimization (compiler command "-mpa").

12-bit chips

  • When using 12-bit controllers (PIC10 and PIC12), the size of pointers to message, simple messages and counting semaphores must be equal to 1 byte.

mikroC PRO for PIC16

  • Version 2.50 PRO or higher required for PIC18
  • Version 3.00 PRO or higher required for PIC12 and PIC16
  • Dynamic timers, messages and queues of messages cannot be allocated in bank2 and bank3 of RAM. The problem is that mikroC PRO can allocate there itself. In this case you should to change the locations of definitions of listed variables. (Soon this limitation will be solved)


  • Since version 4.104 the compiler has an error. Due to this error, the compiler can't build a program that uses OSA. Please, use other versions (OSA was checked with: 4.023, 4.069, 4.084, 4.099, 4.102, 4.105)

IAR (AVR and STM8)

  • Works in C-mode only (not C++).
  • Optimization cross-call should be switched OFF.


  • OSA foulder and project foulder should be allocated on same logical drive (for example both on "C:\…").


  • Only chips with ROM 64K and less are supported

Thanks to

Thanks to all who took part in identifying and correcting bugs. Most thanks to Vadim Frank and to D. Ivanov who was a most active assistant and showed patience and perseverance.

Special thanks to Roger Burrows who corrected a lot of my errors in the English documentation.

Also thanks to Alex B. who provided the site for documentation and assistance in its placement on the site.

en/osa/ref/introduction/intro.txt · Last modified: 07.10.2010 13:58 (external edit)
Creative Commons License Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki