There are currently two ports for the Microchip PICMicro PIC18 series of embedded microcontrollers. This page relates only to the port using the MPLAB C18 compiler.
The PICMicro PIC18 RTOS port was developed on a 40 pin PICmicro prototyping board from
Forest Electronic Developments (FED) (instructions are provided should you wish to use an alternative development board).
A PIC18F452
microcontroller was installed. This prototyping board allows for in system flash programming by means of the PICPROG
utility, also supplied by FED.
The MPLAB C18 development tools were used, along with the MPLAB IDE front end. The real time simulator included with the MPLAB development tools download was utilised for debugging.
Unfortunately the compiler is not free or open source, and there does not seem to be a suitable open source alternative. The IDE and simulator are however free, and the development tools can be downloaded with a generous evaluation period. A limited functionality student version is also available.
As downloaded this demo application does not demonstrate the use of co-routines. See the co-routine documentation page for information on how co-routine functionality can be quickly added to this demonstration.
See also the FAQ My application does not run, what could be wrong?
See the Source Code Organization section for a description of the downloaded files and information on creating a new project.
The MPLAB PIC18 demo application project files are located in the Demo/PIC18_MPLAB directory.
The demo application workspace includes the following three projects.
The RTOS demo application project files contain absolute path definitions. If anybody can get
around this problem then please let me know how! To use the project files on your system it is likely the paths will
require modification. This is easiest to achieve by opening the RTOSDemo1.mcp, RTOSDemo2.mcp and RTOSDemo3.mcp files
in a text editor and editing as necessary. Search for the string "e:\dev" to find the lines that require
modification.
The prototyping board is programmed using the PICPROG utility supplied by FED. PICPROG can open intel HEX and binary files. I have however found more often than not that HEX files are not recognized correctly (some incompatibility between HEX file formats?). When a file is opened and viewed from within PICPROG, the first byte should be E7(HEX) - a GOTO instruction. If this is not the case, convert the HEX file to a binary and open it as such (instruction follow).

After building an application, check the size of the .tmpdata and MATH_DATA sections within the map file. If these total more than 19 bytes the constant portCOMPILER_MANAGED_MEMORY_SIZE and the macros portSAVE_CONTEXT and portRESTORE_CONTEXT will have to be modified accordingly. It is not clear whether this data block will always be of fixed size, or be application specific.
Source/Portable/MemMang/heap_1.c is included in the PICMicro demo application projects to provide the memory allocation required by the real time kernel. Please refer to the Memory Management section of the API documentation for full information.
The linker script provided with the demo application creates a large memory area to hold the heap defined within the heap_1.c file. This arrangement is effective for the demo applications.
The MPLAB development tools have the following restriction as described by the linker manual:"You must not combine data memory regions when using MPLINK Linker with MPLAB C18 C compiler. MPLAB C18 requires that any section be located within a single bank.". Depending on the memory requirements of user applications it might be that this restriction is violated. John Franklin has kindly provided an example of how this situation can be avoided, should the need arise. Johns example files, along with a pdf file containing more detailed information, can be obtained here.
As with all the ports, it is essential that the correct compiler options are used. The best way to ensure this is to base your application on the provided demo application project.
Configuration items specific to this port are contained in Demo/PIC18_MPLAB/FreeRTOSConfig.h. The constants defined in this file can be edited to suit your application. In particular - the definition configTICK_RATE_HZ is used to set the frequency of the RTOS tick. The supplied value of 1000Hz is useful for testing the kernel functionality but is faster than most applications
Each port #defines 'portBASE_TYPE' to equal the most efficient data type for that processor. This port defines portBASE_TYPE to be of type char.
Set the definition configUSE_PREEMPTION within Demo/PIC18_MPLAB/FreeRTOSConfig.h to 1 to use pre-emption or 0 to use co-operative.
The supplied serial port drivers are written to test some of the real time kernel features - and they are not intended to represent an optimised solution.
When using the MPLAB IDE simulator, check to ensure the watchdog is disabled by using the "Configuration Bits" option on the MPLAB IDE Configuration menu. Also, remember to clear the file registers between each execution. This is done using the Debugger->Clear Memory menu item within MPLAB IDE.
The FED prototyping board was chosen for its low cost, but it should be easy to port the demo applications to an alternative platform.
Any and all data, files, source code, html content and documentation included in the FreeRTOS distribution or available on this site are the exclusive property of Richard Barry.
See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Richard Barry.