TOP Contributors

  1. MIKROE (2650 codes)
  2. Alcides Ramos (350 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (136539 times)
  2. FAT32 Library (69736 times)
  3. Network Ethernet Library (55842 times)
  4. USB Device Library (46178 times)
  5. Network WiFi Library (41801 times)
  6. FT800 Library (40989 times)
  7. GSM click (28923 times)
  8. PID Library (26384 times)
  9. mikroSDK (26283 times)
  10. microSD click (25299 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
Library

RTOS for PIC32

Rating:

5

Author: dany

Last Updated: 2017-09-30

Package Version: 1.2.0.0

Category: Other Codes

Downloaded: 2992 times

Followed by: 3 users

License: MIT license  

Pre-emptive RTOS for PIC32, written (almost entirely) in mikroPascal/mikroBasic/mikroC.
The way of working is very easy to understand. The functionality is kept very limited with respect to other RTosses, to keep it simple.
The library code only consists of 1 .mpas file...

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "RTOS for PIC32" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "RTOS for PIC32" changes.

Do you want to report abuse regarding "RTOS for PIC32".

  • Information
  • Comments (3)

Library Blog

Pre-emptive RTOS (scheduler) for PIC32 and mP/mB/mC PRO.

Features:

- Delays in tasks performed by the RTOS (using OS_Delay in stead of delay_ms), giving other tasks the possibility to execute during that waiting time.
- Binary and Counting semaphores, with or without timeout.
- Starting, stopping and replacing (stop current task, start another one) tasks.
- Signalling semaphores both from interrupts and the main thread.
- Task priorities (priority 0 being the highest one)

- Tasks are executed in the main thread, not in an interrupt routine.
- The RTOS timebase is timer 1, using interrupt priority 6 (to prevent the usage of the shadow register set). So, all timed activities have a resolution of 1 timertick. A very suitable value for 1 timertick is e.g. 1 millisecond.
- The max task execution time is 10 timerticks. This is the longest time a task will be executed, after that another task (or the same, depending on eligibility of other tasks) will be chosen for execution. If a task is pre-empted by another one the execution time will be shorter of course.
This automatic task switching every 10 timerticks can be disabled by defining a compiler directive. Doing this the RTOS becomes a CRTOS (cooperative RTOS).
- Pre-emptive (if a task with a higher priority than the current one executed becomes eligible then it gets executed first)
- Tasks with the same priority are executed in a "round Robin" (sequential with wrap around) manner.
- Idle procedure (optional)
- Stack usage measurement (optional)
- Critical sections in the tasks are possible.

Have fun!

Keywords:

- scheduler
- pre-emptive
- priority
- semaphore
 


2015-07-30: Changed the documentation (stack usage function) and the library dependancies in the package.


2015-08-06, version 1.1:

- Added the "Critical Section" procedures (Enter- and LeaveCriticalSection)
- R1 is not part of the context any more (GP never changes)
- Made the Timer1Int routine does not make any "calls" anymore (could give problems)


2015-08-09, v 1.2:

- Added OS_NO_AUTO compiler directive (in RTOS_Defines.pld) to disable automatic task switching,  setting this directive makes the system a cooperative RTOS (CRTOS)
- Always restart the 10 timerticks counter when a new task is (to be) selected
- Forced the first task selection now (in OS_Run): faster starting of first task
- Added the "Check_Events_ISR" again in the semaphore test/read routines to prevent 1 timertick delay
- Made "RestoreInterrupts" inline code. (no calls are allowed in the timebase interrupt routine)


2015-08-14:
- Added the instructions "DI" and "EHB" to the epilogue code of the OS interrupt routine.
- Fetched the interrupt Priority from the "Cause" coprocessor register to put in the "Status" register
- Added always a "rdpgpr sp, sp" to the beginning of the interrupt prologue


2015-08-16: Added the mB version of the library (not tested, only compiled). 


2015-09-20: Updated the examples: the memory manager was not initialised in them... Sorry for the inconvenience.


2015-09-21: Added, thanks to aCkO the mC for PIC32 version package (.mpkg) and the updated the zip file. I hope there is a lot of interest from the mC community!

ALSO FROM THIS AUTHOR

DS1820 Examples

0

4 examples of driving the DS1820, DS18S20 and DS18B20 digital temperature sensors, using the TempSensors and the OW_Utilities libraries. The examples can also be used with PIC24 (small changes in processor initialisation needed).

[Learn More]

Article: Record Member alignment for PIC24/dsPIC and PIC32

1

Describes how record members are stored internally in their records, and what problems to expect if that is not taken into account.

[Learn More]

USB HID CDC MSD composite device

5

This project uses all the available types of USB devices in the USB_OA library: HID (application echos chars send by the PC to the PC), CDC (application echos chars send by the PC to the PC), MSD (the contents of an SD/MMC card is presented to the PC as an extra drive).

[Learn More]