## HomeEmbeddedmKernel

mKernel is a small operating system intended for the PIC18Fx550 chip using an API OSEK/VDX like system build approach.  I started this project SDCC. The memory foot print  was consuming 80% of the code space. So the basic idea of Mkernel was born.

Besides of beeing simple and small, starting with Version 0.6.x the kernel API will be developed based along the OSEK/VDX specification since i like to reuse the mature semantics of the OSEK/VDX specifications as long as it creates no addtional burden.  Specially the idea of leaving the creation of the complete system to tools  using a specification language  as input has become a key element of Mkernel.

Even though, mkernel is not intended as a OSEK/VDX compliant implementation, it supports the following OSEK/VDX inspired features:

• Resources
• Counter & Alarms
• Process communication based on OSEK/VDX like event passing
• OIL Systembuilder
• Process/Interrupt handler communication based on events and resources.
• Simple device model
• Drivers for most of the built in devices of the PIC18f4550 (ADC,PWM,CVREF, I2C, COMP).
• Drivers for the IOR5E board

## Getting started with mkernel

The kernel is implemented as a set of libraries which are linked with the application part.  Lets assume we like to write an application which is intended to toggle an LED. The first thing you need is an alarm which fires periodically and a task which does the actual toggeling.

The implementation of such a task rather straight forward:

static byte led_state = 0;

led_state = !led_state;
if(led_state) led_on(1); else led_off(1);
}

This task needs to be associated with an periodic alarm. This is done by creating three entries in the system defintion file of the application. The following definitions do specify a counter which is associated with an alarm which activates the task ToggelLED.

COUNTER ledCounter {
MAXALLOWEDVALUE = 20;
TICKSPERBASE = 10;
};

ALARM ledAlarm {
COUNTER = ledCounter;
AUTOSTART = TRUE { APPMODE = IOR5E;};
};


The properties of the actual task need to be specified as well.

TASK ToggelLED {
PRIORITY = 1;
STACKSIZE = 96;
SCHEDULE = FULL;>
AUTOSTART = FALSE;
};


Running the OIL compiler will provide the glue code needed to maintain the counters and the provide the task.