The cocoOS used in PICmicro MID-RANGE MCU FAMILY

Configuring cocoOS

The cocoOS used in PICmicro MID-RANGE MCU FAMILY

Postby peter » Wed Apr 15, 2015 5:00 pm

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 http://www.cocoos.net

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 http://www.cocoos.net/started.html & http://www.cocoos.net/tasks.html

8. Compile and run!
peter
Site Admin
 
Posts: 24
Joined: Wed Mar 07, 2012 9:32 am

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

Postby wooda » Tue Feb 16, 2021 2:28 am

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)
{
//
task_open();
for(;;)
{
os_tick();
ostickcounter++;
sem_wait(bin_OSTCK_sem);
}
task_close();
}

and in timer ISR it is :

extern Sem_t bin_OSTCK_sem;
void TMR0_ISR(void)
{
// clear the TMR0 interrupt flag
PIR0bits.TMR0IF = 0;
if(TMR0_InterruptHandler)
{
TMR0_InterruptHandler();
}
// os_tick_inISR();
// event_ISR_signal(OSTCK_Event);
sem_ISR_signal(bin_OSTCK_sem);
// 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,
wooda
 
Posts: 3
Joined: Sat Oct 20, 2018 8:02 am


Return to Configuration

Who is online

Users browsing this forum: No registered users and 1 guest

cron