Page 1 of 1

The cocoOS used in PICmicro MID-RANGE MCU FAMILY

PostPosted: Wed Apr 15, 2015 5:00 pm
by peter
Here is a short guide to get cocoOS compiled with the XC8 compiler:

Tested with Microchip MPLAB XC8 C Compiler (PRO Mode) V1.34( the MPLAP X IDE version2.35)

1. Download the latest source from

2. Create a project that includes all the .c and .h files.

3. Add #include <xc.h> and #include "cocoos.h" in projects main.c file.

4. In os_defines.h:
- Add #include <stdint.h> (This will be fixed in cocoOS 4.1.0)
- Define the number of tasks, queues, semaphores and events. Set to 0 if not used to reduce RAM usage.
- Comment the define for ROUND_ROBIN if priority based scheduling is desired.
- Define the size of memory pointers (for MID-RANGE family: typedef uint16_t Mem_t)

5. In os_port.h:
- add #include <xc.h>
- #define os_enable_interrupts() GIE=1
- #define os_disable_interrupts() GIE=0

6. Create HW timer ISR that calls os_tick() function. you decide the tick interval...

7. Create test programs as shown in &

8. Compile and run!

Re: The cocoOS used in PICmicro MID-RANGE MCU FAMILY

PostPosted: Tue Feb 16, 2021 2:28 am
by wooda
Well, this post is imprtant for new users.
I found some trouble in timer ISR to push the os_tick()
after a few works, find this code works:

void Task_OSTick(void)

and in timer ISR it is :

extern Sem_t bin_OSTCK_sem;
void TMR0_ISR(void)
// clear the TMR0 interrupt flag
PIR0bits.TMR0IF = 0;
// os_tick_inISR();
// event_ISR_signal(OSTCK_Event);
// add your TMR0 interrupt custom code
the ‘//’code is not successful lines and i keep it to show my try.

the cost is one task,
the code works in MPLABX IDE V4.20 with compiler xc8 v1.4,