Relationship between PSoC Creator heap/stack and FreeRTOS heap/stack

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I'm a bit confused on this one.

   

The PSoC Creator design-wide resources editor has system parameters for heap size and stack size. What exactly is stored in this heap? If I understand properly there isn't any dynamic allocation at all by default, right? Or is there?

   

Do I need to set it up so that my FreeRTOS heap size < the PSoC Creator heap size? I'm thinking no, because I think the FreeRTOS heap reservation just reserves another area entirely?

   

As far as the stack parameter is concerned, how does this interact with the FreeRTOS stack? Again, if I understand correctly, FreeRTOS allocates space for task stacks from its own heap when the task is created. (I'm pretty sure about this, because the stack size is dynamically supplied to the task creation function.) Does this mean that I can get away with a very small PSoC Creator stack size, because that stack is only used for initialization stuff and for the scheduler itself, and is disjoint from the actual task stacks?

   

Can anyone shed some light on this? I want to make sure I am not using lots of memory for nothing, but at the same time overflowing these types of limits can be a real pain to debug.

0 Likes
2 Replies
Anonymous
Not applicable

> The PSoC Creator design-wide resources editor has system parameters

   

> for heap size and stack size. What exactly is stored in this heap?

   

 

   

Presumably, as per normal, memory returned by any call to malloc() will come from the heap.

   

 

   

>If I understand

   

> properly there isn't any dynamic allocation at all by default, right? Or is there?

   

 

   

?

   

 

   

> Do I need to set it up so that my FreeRTOS heap size < the PSoC Creator heap size?

   

 

   

Please see the memory management section of the FreeRTOS.org web site.

   

In this case, FreeRTOS does not use the heap set up by the Cypress tools unless heap_3.c is included in your project, and it uses the stack set up by the Cypress tools as the interrupt stack.

   

 

   

> I'm thinking no, because I think the FreeRTOS heap reservation just reserves another

   

>area entirely?As far as the stack parameter is concerned, how does this interact with

   

>the FreeRTOS stack? Again, if I understand correctly, FreeRTOS allocates space for

   

> task stacks from its own heap when the task is created. (I'm pretty sure about this,

   

> because the stack size is dynamically supplied to the task creation function.)

   

 

   

Yes - as per the link above.

   

 

   

> Does this mean that I can get away with a very small PSoC Creator stack size, because

   

> that stack is only used for initialization stuff and for the scheduler itself, and is disjoint from

   

> the actual task stacks?

   

 

   

It needs to be at least big enough for main to run to the point where vTaskStartScheduler() is called, and at least big enough to hold a complete interrupt stack frame, which may be nested several interrupts deep, depending on what your application is doing.

   

 

   

Regards,

   

Richard.

   

 

   

FreeRTOS

   

Designed for Microcontrollers, more than 7000 downloads per month

0 Likes
Anonymous
Not applicable

Thanks Richard, that's exactly the information I was looking for.

   

What I had meant by "If I understand properly there isn't any dynamic allocation at all by default, right? Or is there?" is that I couldn't find any definition for malloc(..) in the autogenerated Cypress libraries or any calls to it, so I wasn't sure if there even was a way to allocate things from the heap whose size is controlled by PSoC Creator.

   

I take your answer to mean that the definition is around somewhere, and so it can be used from user-written code?

   

Again, thanks very much.

0 Likes