error in heap_1.c for IAR, ARM7 port?

gasilvis wrote on Saturday, April 18, 2009:

void *pvPortMalloc( size_t xWantedSize )      

xWantedSize is in bytes, but gets compared to configTOTAL_HEAP_SIZE which is in words:

/* Check there is enough room left for the allocation. */
if( ( ( xNextFreeByte + xWantedSize ) < configTOTAL_HEAP_SIZE )) &&
            ( ( xNextFreeByte + xWantedSize ) > xNextFreeByte )    )/* Check for overflow. */

My change is:
if( ( ( xNextFreeByte + xWantedSize ) < (configTOTAL_HEAP_SIZE * sizeof( portSTACK_TYPE ))) &&


sotd wrote on Saturday, April 18, 2009:

configTOTAL_HEAP_SIZE is also in bytes? Line 104
unsigned portCHAR ucHeap[ configTOTAL_HEAP_SIZE ];

gasilvis wrote on Saturday, April 18, 2009:

Thank you!

Is there another forum to which this error should be sent or will the author pick it up from here?

I don’t have my application running yet under the rtos; still trying to figure why at startup it never comes out of the idle task.


rtel wrote on Saturday, April 18, 2009:

I cannot see that there is a problem.  The wanted size is specified in bytes (the stack size * the size in bytes of each stack item) and configTOTAL_HEAP_SIZE is used to dimension a char array, so is also in bytes.  It would appear to be a bytes for bytes comparison.  Am I missing something?


gasilvis wrote on Saturday, April 18, 2009:

Greetings Richard,

My bad.

configTOTAL_HEAP_SIZE is indeed in bytes. I had been looking at the heap arguments for the createTask which is in words.

One other note on the FreeRTOSconfig.h:

#define configCPU_CLOCK_HZ       should be, for the ATM7, the peripheral clock.  Often, but not necessarily, the same as the CPU clock.

Its great having the source to work with, but I confess I have still not got the RTOS to go. It dies when it calls vPortStartFirstTask().


rtel wrote on Sunday, April 19, 2009:

Make sure the processor is in Supervisor mode when main() is called.  It must be in supervisor mode when vPortStartFirstTask() is executed.