PIC Memory Problem

nobody wrote on Wednesday, May 09, 2007:


I’m using Freertos with PIC 18F8821, i have 5 tasks running well in differents projects but when i put all together it works just for 10 seconds, then the program reset…

Can you help me please? i’m changing the value of the  #define portTOTAL_HEAP_SIZE but doesn’t work…

Thanks for all your ideas!!! i’m in big problems with that…


rtel wrote on Thursday, May 10, 2007:

Have you checked the return value of xTaskCreate() to make sure the tasks are actually being created successfully?  Also check that the tasks are not running out of stack space - you allocate the size of the stack as a parameter to the xTaskCreate() API function when the task is created.


nobody wrote on Thursday, May 10, 2007:

thanks for your help, i’m sure that all the task are succesfully create like that

check=sTaskCreate( Task_Main, ( const portCHAR * const ) "Main", portMINIMAL_STACK_SIZE, ( void * ) pParamEvento1,mainTASK_MAIN, NULL );

and each task has define the portMINIMAL_STACK_SIZE with the minimun value to work… at this moment i have:

check=sTaskCreate( Task_Main, ( const portCHAR * const ) "Main", 120, ( void * ) pParamEvento1,mainTASK_MAIN, NULL );

check=sTaskCreate( Task_INFR, ( const portCHAR * const ) "Main", 110, ( void * ) pParamEvento1,mainTASK_MAIN, NULL );

check=sTaskCreate( Task_OBSRV, ( const portCHAR * const ) "Main", 120, ( void * ) pParamEvento1,mainTASK_MAIN, NULL );

check=sTaskCreate( Task_Marcadores, ( const portCHAR * const ) "Main", 90, ( void * ) pParamEvento1,mainTASK_MAIN, NULL );

check=sTaskCreate( Task_PosXY, ( const portCHAR * const ) "Main", 150, ( void * ) pParamEvento1,mainTASK_MAIN, NULL );

and the #define portTOTAL_HEAP_SIZE ( 3150 )

Check is 1 when i’m using the mplab’s debuguer (breakpoints), but it works for few seconds after it reset without breakpoints… i’m thinking to change the pic for one with much memory like 8722 … do you think it can works? or i will have the same problem?

PIC 18F8621
     Program Memory                      Data Memory
Flash       #Single-Word       SRAM(bytes)    EEPROM(bytes)
(bytes)      Instructions
64K            32768            3840              1024

PIC 18F8722
     Program Memory                      Data Memory
Flash       #Single-Word       SRAM(bytes)    EEPROM(bytes)
(bytes)      Instructions
128K          65536               3936            1024

The PosXY task works with 20 differetns float variables, so when i put the other tasks all is good… bur when i put the PosXY with the others the problem appear…

I don’t know what else can i do… i have to work whit this floats … so do you have an idea??

Thanks again for your help… i’m very worried i have to finish it very soon…

Thanks and have a nice day!!!

nobody wrote on Thursday, May 10, 2007:

Are the floating point variables on the stack?  If so then try declaring them static.

Is the .math and .tmpdata section sizes equal to the setting in the FreeRTOS configuration file as described on the PIC18 page?

nobody wrote on Thursday, May 10, 2007:

Thanks for your help… this is the task:

i defined all the variables out of the task at the beggining of the program…(only this task will use it)

float fDesplazamiento;

float fDesplazamientoDerecho;
float fDesplazamientoIzquierdo;
float Xnueva=0;
float Ynueva=0;

float fThetan_1;
float fXn;
float fYn;
float fThetan;
char estadoAnterior;
char estadoAnterior1;

static volatile unsigned portCHAR cont = ( unsigned portCHAR ) 1;
static volatile char a=0;
static volatile char b=0;
float fXnA=0, fYnA=0,fThetanA=0;
float Xa, Ya;
float acumuladorx=0, acumuladory=0;

float newX=0;
float newY=0;
float separacion=10;
static volatile  byte cual;
static volatile  byte antcual=0;

float ang=0;
float antnewx=0;
float antnewy=0;
char sensor;

static void Task_PosXY( void *pvParameters )
Contador algo;
portTickType xDelayTime = mainNO_ERROR_CHECK_PERIOD;
char u;
byte centro;
int casillaX=1;
int casillaY=1;

Param_evento *pParamEvento, ParamEvento;
pParamEvento = (Param_evento *) pvParameters;

acumuladorx=0, acumuladory=0;



               //…task code

         }//fin for

i will try to put it static… the problem is that i have to use one more task… so what do you think to change the pic ?

thanks for all your help!!!!

nobody wrote on Thursday, May 10, 2007:

Hello!! one question more if i have more than 19 bytes who can Freertos works when i have only this task?

and can you help me to know how is the way to know the value that you have to change for this constant?


thanks so much!..

nobody wrote on Thursday, May 10, 2007:

You have to look in the map file at the size of the .tmpdata and .mathdata sectors.  This is why the C18 compiler is not a good C compiler.  Search for portCOMPILER_MANGAED_MEMORY_SIZE on the following page http://www.freertos.org/a00097.html (shouldnt that be configCOMPILER_MANAGED_MEMORY_SIZE?)

nobody wrote on Friday, May 11, 2007:

Thanks !! so much for your help it seems to work!!!! i changed the constant defined and the macros now is working everything!!!

Thanks again and have a very nice day!!!!!!