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

cross mob

Set Stack and Heap Size for PSoC 6 MCU Devices – KBA225135

Set Stack and Heap Size for PSoC 6 MCU Devices – KBA225135

Community-Team
Employee
Employee
50 questions asked 10 questions asked 5 questions asked

Author: ShipingW_81           Version: *A

Translation - Japanese: PSoC 6 MCU デバイスのスタックとヒープサイズの設定 - KBA225135 - Community Translated (JA)

Question:

How do I set the stack and heap for PSoC® 6 MCU devices?

Answer:

To modify the stack/heap size for PSoC 6 MCU devices, use one of the following two methods:

Method 1:

Add the heap and stack size as macros to compiler settings in PSoC Creator™ (Project > Build settings > CM0+ or CM4 > Compiler). For instance, define __STACK_SIZE=400 for defining a stack of size 400 bytes and __HEAP_SIZE=400 for defining a heap of size 400 bytes in the Preprocessor definitions under the General compiler settings as shown in Figure 1. Note that you will have to define this for each core, toolchain, and both "Release/Debug" configurations.

Figure 1. Modifying the heap and stack size in PSoC Creator

pastedImage_8.png

In ModusToolbox, select the application project (_mainapp for CM4 and _mainapp_cm0p for CM0+) and go to Project > Properties > C/C++ Build > Settings > GNU ARM Cross Assembler. Define __STACK_SIZE=400 for defining a stack of size 400 bytes and __HEAP_SIZE=400 for defining a heap of size 400 bytes in the defined symbols under Preprocessor as shown in Figure 2.

pastedImage_4.png

Method 2:

Look for the startup files in the source folder of both CM4 and CM0+. i.e., startup_psoc63_xxx.s/S in PSoC Creator and startup_psoc6_0x_xxx.s/S in ModusToolbox. Note these startup files are specific to each toolchain. In the file, locate Heap_Size and Stack_Size definitions and edit the values as per your requirement. Note that for IAR Embedded Workbench, this is different: the heap/stack sizes are defined in the linker (.icf) file - __ICFEDIT_size_cstack__ and __ICFEDIT_size_heap__.

Cypress recommends to use the preprocessor settings (Method 1) for modification rather than editing the files (Method 2) as the former approach is cleaner and maintainable in the long-run when the source files are updated.

0 Likes
2214 Views
Contributors