RAM usage calculation in PSoC1




Question: The CY8C21x34 is supposed to have 512 bytes. However, the compiler only reports 256 bytes in the RAM calculation. For example, when 62 bytes of RAM are used, the compiler reports that the RAM is 24% full. 




What is the reason for this behavior?


Response: In CY8C21x34, there are two RAM pages(0 and 1). Page 1 is used for stack. By default offset address for stack on this page is kept 0. So, 256 bytes are kept for stack. While calculating RAM usage, ImageCraft compiler does not include RAM which has been used for Stack.

You can change the stack offset to some higher value by opening "Project --> settings --> Build--> compiler" menu.

Now set stack page offset value to say 50. No, stack will start from 0x50 on page 2, freeing up 80 bytes for general purpose RAM variables.