Error: Cannot allocate space for 'data' area

Question: While building a project, I get the error "Cannot allocate space for 64 bytes for 'data' area"?  What is this error and how do I fix this?



This error is generated when the RAM is not enough to fit the global variables.  In devices with 256 bytes of RAM, the error will occur if the RAM required for the globals is more than 256 bytes.  The only solution here is to optimize the global variables and reduce RAM usage.

In devices with more than 256 bytes of RAM (Large Memory Model devices), by default the last page of RAM is allocated for stack.  For example, a CY8C21x34 device has 512 bytes of RAM.  By default, the compiler allocates 256 bytes of RAM in the second RAM page for stack.  Because of this only 256 bytes of RAM are available for global variables.  Go to Project >> Settings menu and modify value of the "Stack Page Offset" parameter to release more RAM for globals.  The parameter takes the value in hex.  For example, if the Stack Page Offset is set to "80", 128 bytes of RAM are released for global variables.