Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

FreeRTOS for PIC18F4550

Posted by elrayes on June 1, 2010
Hi All

I'm trying to modify FreeRTOS for Microchip PIC18F family to work with PIC18F4550 microcontroller, I got error message concerning udata_heap_1.o file, seems to me the error in the linker script that the heap is too large and can't fit within the memory allocated to in the PIC18F4550, please if anyone faced similar problem and was able to solve it let me know.
Thanks


RE: FreeRTOS for PIC18F4550

Posted by Ken Pettit on September 25, 2010
Hi kelrayes,

Did you ever resolve this porting issue? I have FreeRTOS running on a PIC18F4682 (which has more RAM), but I have also used the 18F4550 before.

Ken

RE: FreeRTOS for PIC18F4550

Posted by elrayes on September 25, 2010
Hi Ken

Actually no, I moved to another RTOS called PICos18, there is a port of it for the PIC18F4550.
However I will be interested to know how did you solve the FreeRTOS issue with the PIC18F4550.

Thanks

RE: FreeRTOS for PIC18F4550

Posted by Ken Pettit on September 27, 2010
The heap_1.c, heap_2.c, etc. files have a statically defined variable called xHeap with a big portCHAR array in them. This is where the "heap" is located. The size of the portCHAR array is determined by the configTOTAL_HEAP_SIZE (plus 4 or 8 based on portBYTE_ALIGNMENT). The static variable xHeap will be located somewhere in RAM by the linker, and must be small enough to fit in the available ram on the PIC.

The PIC18F4550 has 2048 bytes of RAM. Assuming you want to reserve bank zero for fast-access variables, Bank 1 for your stack and Bank 2 for global variables, this would leave 1280 bytes for "heap" (probably less because the PicKIT2 probably wants 10 bytes for debugging). So your configTOTAL_HEAP_SIZE should be something like 1260 or less (or much less if you have a lot of global variables).

I typically copy the default linker script (18f4550_e.lkr, etc.) into my project directory and make custom modifications to control the link process. I create a DATABANK NAME=freertos_heap and give it a specific RAM range in the linker script. Then in the heap_2.c file, just before the static declaration of xHeap, I add a line like: #pragma udata freertos_heap = 0x300 (or whatever).

Ken

RE: FreeRTOS for PIC18F4550

Posted by Robin on October 8, 2010
May i know whether FreeRTOS works fine with 18F4550. I mean to ask does it work with all different priorities and multiple tasks.

RE: FreeRTOS for PIC18F4550

Posted by Ken Pettit on October 8, 2010
I don't see any reason why it wouldn't. As I mentioned, I have it running on a PIC18F4682 which is fairly similar to the 4550 (which I have also used recently with no RTOS). The biggest differences with the 4682 are the increased RAM & FLASH and the substitution of the USB controller in favor of a CAN controller. Otherwise, the peripherals are basically the same, at least any that would affect the operation of FreeRTOS.

Ken

RE: FreeRTOS for PIC18F4550

Posted by Robin on October 8, 2010
But, can you see the tasks in RTOS viewer in MPLAB? And please can you help me with modification of 18f4550 linker.

RE: FreeRTOS for PIC18F4550

Posted by elrayes on October 8, 2010
Hi All

Thanks for your replies, but I moved to another RTOS more convenient for the PIC18F4550 called PICos18 and so far its working fine.

Have a great day
El-Rayes

RE: FreeRTOS for PIC18F4550

Posted by Ken Pettit on October 8, 2010
Hi robinjee,

Well your linker script will depend heavily on your application. Are you using USB? If so, how much RAM does your USB solution require? The default PIC18F4550 linker script uses RAM from 0x400 - 0x7FF for USB, but you may not require this much. So you need to remove some of the DATABANK declarations to free up space for your heap. Keep as much for USB, global variables, etc as needed, then assign the rest of RAM to FreeRTOS, something like:

// $Id: 18f4550_e.lkr,v 1.4 2004/08/23 18:08:22 curtiss Exp $
// File: 18f4550_e.lkr
// Sample linker script for the PIC18F4550 processor

LIBPATH .

FILES c018iz_e.o
FILES clib_e.lib
FILES p18f4550_e.lib

CODEPAGE NAME=vectors START=0x0 END=0x29 PROTECTED
CODEPAGE NAME=page START=0x2A END=0x7FFF
CODEPAGE NAME=idlocs START=0x200000 END=0x200007 PROTECTED
CODEPAGE NAME=config START=0x300000 END=0x30000D PROTECTED
CODEPAGE NAME=devid START=0x3FFFFE END=0x3FFFFF PROTECTED
CODEPAGE NAME=eedata START=0xF00000 END=0xF000FF PROTECTED

DATABANK NAME=gpr0 START=0x0 END=0xFF
DATABANK NAME=gpr1 START=0x100 END=0x1FF
DATABANK NAME=freertos_heap START=0x200 END=0x5FF PROTECTED
DATABANK NAME=usb6 START=0x600 END=0x6FF PROTECTED
DATABANK NAME=usb7 START=0x700 END=0x7FF PROTECTED
ACCESSBANK NAME=accesssfr START=0xF60 END=0xFFF PROTECTED

SECTION NAME=CONFIG ROM=config

STACK SIZE=0x60 RAM=gpr1


In this example, the FreeRTOS heap and it's control variables occupy 0x200-0x5FF = 1K RAM. Next you need to link in one of the heap source files (heap1.c, heap2.c or heap3.c depending on your need to free memory dynamically). In the selected heap#.c file, before the declaration of xHeap, add a pragma line telling the linker to locate the variables in the freertos_heap section like so:

#pragma udata freertos_heap = 0x200
static union xRTOS_HEAP
{
#if portBYTE_ALIGNMENT == 8
volatile portDOUBLE dDummy;
#else
volatile unsigned portLONG ulDummy;
#endif
unsigned portCHAR ucHeap[ configTOTAL_HEAP_SIZE ];
} xHeap;


Next set the configTOTAL_HEAP_SIZE value in your FreeRTOSConfig.h file so it is 8 bytes less than the memory allocation size (1K in this case). It must be 8 bytes less than 1K because of the heap management variables. Of course you need to specify the actual RAM addresses (0x200 vs 0x300, etc.) and assign the memory in case you need more or less than 1K.

Ken

RE: FreeRTOS for PIC18F4550

Posted by rfk fun on December 13, 2010
Please reply !!!

I need the example code of PIC18F4550 with Free RTOS!!
Any clue? Please help!!


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists