Programming Microcontrollers In C:Data Types

Data Types

The C51 compiler provides the standard C data types and in addition several extended data types are offered to support the 8051 microcontroller family. Table 2.1 lists the available data types (see the C51 reference manual for more information).

Some of the data types are described below in more detail.

Programming-Microcontrollers-in-C-00[16]

signed char/unsigned char

These data types are as in standard C language and are used todeclare signed and unsigned character variables. Each character variable is 1 byte long (8 bits). Signed character variables range from -128 to +127; unsigned character variables range from 0 to 255.

Programming-Microcontrollers-in-C-00[10]

Programming-Microcontrollers-in-C-00[15]

signed short/unsigned short

These data types are as in standard C language and are used todeclare signed and unsigned short variables. Each short variable is 2 bytes long (16 bits). Signed short variables range from -32 768 to +32 767 and unsigned short

variables range from 0 to 65 535.

Programming-Microcontrollers-in-C-00[4]

signed int/unsigned int

As in the standard C language, these data types are used todeclare signed and

unsigned integer variables. Integer variables are 2 bytes long (16 bits). Signed integers range from -32 768 to +32 767 and unsigned integers range from 0 to

65 535.

Example:

Programming-Microcontrollers-in-C-00[5]

sfr

This data type is similar tosbit but is used todeclare 8-bit variables.

Example:

Programming-Microcontrollers-in-C-00[8]

Leave a comment

Your email address will not be published. Required fields are marked *