ARM Technical Support Knowledge Articles

DATA_GROUP AND STACK PROBLEMS

Applies to: C51 C Compiler

Answer


Information in this article applies to:


QUESTION

When using the C51 compiler package, the linker generates a section in the DATA memory called DATA_GROUP. What is this thing and how can I reduce its size to get more stack space?

ANSWER

The C51 compiler does not pass parameters on the STACK. Instead, local variables and function arguments are stored in DATA, IDATA, or XDATA memory and are overlaid where possible. The overlaid memory used for local variables and arguments is grouped into the DATA_GROUP (for DATA variables), the IDATA_GROUP (for IDATA variables), and the XDATA_GROUP (for XDATA variables). These groups are created and managed by the linker.

To maximize the available DATA space, you should minimize the use of global variables and use local or automatic variables instead. Global variables are allocated with a unique, non-overlayable memory address. In the DATA area this method can be very wasteful.

When linking, the linker performs a program flow analysis to determine which leg of the main program uses the most local memory space. It then allocates the rest of the variables out of this area. Because of the scope of local variables, memory conflicts don't happen and memory is used very efficiently.

One of the benefits of this scheme is that STACK requirements are very minimal. If you need more STACK space you should specify the use of external memory for large data types like arrays and communication buffers. This assumes that such space is available. Another good idea is to minimize the use of variables inside interrupt routines. These these variables are allocated their own unique DATA space.

For more information, refer to Application Note 101.

Article last edited on: 2006-08-01 13:22:00

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential