Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Heap 2 model into PIC18

Posted by Marcelo Adrian Lorenzati Sanz on July 27, 2008
Hi People I wonder if you could help me with this.
I´ve been trying for a while Freertos on PIC18 microcontrollers with heap_1 model but now I´m using the heap_2 model and I find an erratic behaviour.
I´m doing a ks108 graphic lcd driver for freertos and I wanted it to be with dinamical allocation of objects.
It was working relatively ok but now It dont.
I´ve modified the linker script for 18F4620 and I´ve been looking in the forum about the portCOMPILER_MANAGED_MEMORY_SIZE issue but couldn´t solve it.
Some task (like the line primitive) when it is context switched get his stack data corrupted.

I´m planning to donate the effort so any kind of help would be accepted.

Is it possible to use it with heap 2 model? If so what I should do to use it correctly?

Let me know and I´ll send you the code, it does some nice things with the LCD :)

Best regards.

RE: Heap 2 model into PIC18

Posted by PICmeup on July 27, 2008
could be just memory fragmentation. Do you check the pvPortMalloc return value for null?

RE: Heap 2 model into PIC18

Posted by Marcelo Adrian Lorenzati Sanz on July 28, 2008
Hi PICmeup,
As example, when the line "initiator" is called asks for a semaphore.
If not Null, it takes the semaphore and starts the line task passing multiple parameters by reference, the semaphore handles is between them.
When the line task ends it "gives" the semaphore and wakes up the "initiator".
I do not receive a NULL to the semaphore and the task initiates correctly BUT when the line task gets context switched a variable used to store the slope of the line is corrupted.
I´ve made a change to the port for PIC18 as others in the forum tried changing portCOMPILER_MANAGED_MEMORY_SIZE to 0x14 and adding a MOVFFPOSTINC0, PREINC1 to the portSAVE_CONTEXT and and a MOVFFPOSTDEC1, POSTDEC0 to the portRESTORE_CONTEXT but without success.


RE: Heap 2 model into PIC18

Posted by Marcelo Adrian Lorenzati Sanz on July 30, 2008
No one has an answer on this?
Is heap_1 the only possible memory model for PIC18?
What do I have to do? start before the scheduler all tasks to allocate memory on the queue, suspend them and then restarted when needed when I need a Task to work when called?

Best regards.

RE: Heap 2 model into PIC18

Posted by Paul_Piak on July 31, 2008

If you change portCOMPILER_MANAGED_MEMORY_SIZE, you should understand that it should be 1 less than .tmpdata+.mathdata
See this message:


RE: Heap 2 model into PIC18

Posted by Marcelo Adrian Lorenzati Sanz on July 31, 2008
Thanks Paul_Piak, I've read It.
I've just tried everything to make it work, but without success.

I tested malloc and free implementations in heap 1 and heap 2 models alone (without starting the OS) and they work fine on the PIC18, that's why I think the problem is with the port implementation for PIC18.
Just when the task get context switched the data gets corrupted.

Has anyone tried heap_2 model into PIC18?
Whats the maximum configMINIMAL_STACK_SIZE for this microprocessor?


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

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers


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

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

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner