2 compiler-specific information, Compiler-specific information, Table 5-2: internal data types – Maxim Integrated 71M6534 Energy Meter IC Family Software User Manual

Page 46

Advertising
background image

71M653X Software User’s Guide

Note: Throughout the Demo Code, an attempt has been made to put the most frequently used variables in the
fastest memory space.

Data Type

Notation

Bits

Bytes

Comments

bit

bool

1

Unique to 8051

sbit

1

Unique to 8051

SFR

8

1

Unique to 8051

SFR16

16

2

Unique to 8051

signed/unsigned char

uint8_t 8 1

ANSI

C

enum

enum

8 or 16

1 or 2

ANSI C

unsigned short

uint16_t

16

2

ANSI C

signed short

int16_t

16

2

ANSI C

unsigned int

uint16_t

16

2

ANSI C

signed int

int16_t

16

2

ANSI C

unsigned long

uint32_t

32

4

ANSI C

float float

32

4

ANSI

C

Table 5-2: Internal Data Types

5.1.2 Compiler-Specific Information

The 8051 has 128 bytes of stack, and this motivates Keil C's unusual compiler design. By default, the Keil C compiler
does not generate reentrant code. The linker manages local variables of each type of memory as a series of overlays,
and uses a call-tree of the subroutines to arrange that the local variables of active subroutines do not overlap.

The overlay scheme can use memory very efficiently. This is useful because the 71M653X chips only have 2k of RAM,
and 256 bytes of internal memory.

The compiler treats uncalled subroutines as possible interrupt routines, and starts new hierarchies, which can rapidly
fragment each type of memory and interfere with its reuse.

To combat this, the following measures were taken when generating the Demo Code:

The code is organized as a control loop, keeping most code in a single hierarchy of subroutines,

• The programmers eliminated unused subroutines by commenting them out when the linker complained

about them. Also, the Demo Code explicitly defines interrupt code and routines called from interrupt code
as "reentrant" so that the compiler keeps their variables on a stack.

When data has a stable existence, the Demo Code keeps a single copy in a shared static structure.

With these measures applied, the Demo Code uses memory efficiently, and normally no memory issues are en-
countered. The Demo Code does not have deep call trees from the interrupts, so "small reentrant" definitions can be
used, which keep the stack of reentrant variables in the fast (small) internal RAM.

The register sets are also in internal memory. The C compiler has special interrupt declaration syntax to use them. The
"noaregs" pragma around reentrant routines stops the compiler from accessing registers via the shorter absolute
memory references. This is because the Demo Code uses all four sets of registers for different high-speed interrupts.

Using "noaregs" lets any interrupt routine call any reentrant routine without overwriting a different interrupt's registers.

v1.1v1.1

TERIDIAN Proprietary

46 of 116

© Copyright 2005-2008 TERIDIAN Semiconductor Corporation

Advertising
This manual is related to the following products: