Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 5 > Relationship between PSoC Creator heap/stack and FreeRTOS heap/stack

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



Relationship between PSoC Creator heap/stack and FreeRTOS heap/stack
Moderator:
ANCY

Post Reply
Follow this topic



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

Doug McClean posted on 01 Jul 2011 7:57 AM PST
Top Contributor
38 Forum Posts

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.




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

FreeRTOS.org posted on 02 Jul 2011 11:45 PM PST

1 Forum Post

> 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



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

Doug McClean posted on 02 Jul 2011 03:00 PM PST
Top Contributor
38 Forum Posts

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.

 






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: KXP; Secondary Owner: VWA; Sunset Date: 01/01/20