PIC Microcontroller Operating System

13,395

Solution 1

I suggest you check out FreeRTOS.

Solution 2

  1. Yes, you can write your own kernel (I have written 2 of my own). Yes you can write it in C for PIC. If you want pre-emptive scheduling, then you're going to have a real tough time avoiding assembly completely when writing the context switch. On the other hand, you can easily write a cooperative kernel purely in C (I have done this myself). (Note that creating an operating system is not a simple task... I'd get your feet wet in pure C first, then USE an OS or two, then try creating one.)

  2. An excellent example of this is FreeRTOS. It has preexisting ports (i.e. MPLAB projects that run without any modification on the Explorer16 demo board) for PIC24F, PIC33F, and PIC32MX (as well as 20-some odd other official ports for other vendors' devices). PIC18F is supported but it's not pretty...

  3. You only need MPLAB to create the kernel (free from Microchip). It can work interchangably with C and assembly. Depending on the processor, there are free versions of their C30 and C32 compilers to go with MPLAB.

  4. PIC is a type of microcontroller, and is a trademark of Microchip. Many other companies make microcontrollers and call them something else (e.g. AVR, LPC, STM32).

  5. Yes, the new version of MPLAB X is supported on Mac, Linux and Windows.

Solution 3

I second the vote for FreeRTOS; we use this all the time on PIC24 designs. The port works well and doesn't use a ton of memory.

Microchip supports many third party RTOSes.

Most have free demo projects that you can download, build in MPLAB, and program onto an Explorer16 board very easily. You can then experiment to your heart's content.

Solution 4

PIC is not a single architecture. PIC10 differs considerably from PIC24, though they and every PIC in between share some commonality. The MIPS based PIC32 on the other hand is an entirely different architecture. So you have to be clear about what PIC you are referring to.

An OS on a PIC does not have to be and RTOS, but that would be ideally suited to the application domain the devices are used in, so anything that were not real-time capable would be somewhat less useful.

There are many RTOS ports already for PIC.

There is nothing special about about a kernel scheduler in terms of development method, C and in most cases a little assembler are all that are necessary - no special tools. You could use 100% assembler if you wished, and this might be necessary to get the smallest/fastest code, but only if your assembler knowledge is better than the compiler's.

PIC is specific to Microchip, though Parallax SX is more or less a clone. Unlike ARM for example, Microchip do not licence the architecture to third-party chip manufacturers or IP providers. No one would want it in any case IMO; there are far better architectures. ARM Cortex-M is particularly suited to RTOS kernel implementation, and AVR's instruction is designed for efficient translation from C source code. Even the venerable 8051 is well suited to RTOS implementation; its eight register banks make context switches very fast (for up to eight threads), and like ARM, 8051 architecture devices are available from multiple manufacturers.

Share:
13,395
Coder404
Author by

Coder404

I make operating systems, websites, and mobile apps (iOS, Android, Nokia). I also do desktop apps (windows and mac).

Updated on June 15, 2022

Comments

  • Coder404
    Coder404 almost 2 years

    I heard it is possible to write an Operating System, using the built in bootloader and a kernel that you write, for the PIC microcontroller. I also heard it has to be a RTOS.

    1. Is this true? Can you actually make an operating system kernel (using C/C++) for PIC?
    2. If yes to 1, are there any examples of this?
    3. If yes to 1, would you need any type of software to create the kernel?
    4. Is Microchip the only company that makes PIC microcontrollers?
    5. Can the PIC microcontroller be programmed on a mac?

    Thanks!

  • Coder404
    Coder404 almost 12 years
    I saw that one and wondered about it. How would you compile, and save that to a PIC? Also I would need the RTOS to have support for detecting buttons and determining if a button had been pressed
  • Oliver
    Oliver almost 12 years
    Check out the "Supported MCUs" page for the supported tools. As for the buttons -- well, this would be your job to implement.
  • Paul R
    Paul R almost 12 years
  • Coder404
    Coder404 almost 12 years
    +1 for fully answering my question! Thank you!
  • Coder404
    Coder404 almost 12 years
    Thank You for your comment. I have decided to make my project FreeRTOS based on an ARM Cortex-M (due to your advice).
  • Clifford
    Clifford almost 12 years
    @Coder: A typical RTOS kernel provides priority based pre-emptive thread scheduling, inter-process communication and usually some minimal framework for interrupt handling. I/O is usually not included. In your case you might have the button input trigger an interrupt then the interrupt signal an event to a thread. Alternatively (and less efficiently) you might have a thread polling the inputs and sending events to other threads.
  • Diego Garcia
    Diego Garcia almost 12 years
    An aditional note is that you can use other IDE's to program for PIC microcontrolers like ccs c from ccsinfo.com one of the best IDE+C Compiler for PIC, or you can use the one from mikroeletronika it supports C, Pascal or Basic for PIC and AVR.