Microcontroller Cross Compiler
Compiler is a program that transforms higher language source code(such as c code) to the lower language code(assembly language/machine code/binary code/object code). This object code can be ported on any target such as microcontroller/processor. The reason for this conversion is to create an executable program for the desired target.
When the target compiled program runs on a computer/platform/system in which CPU/operating system is different from where compiler is installed,this compiler is referred as cross-compiler.
Tools such as µVision are widely used as compiler for different microcontroller variants. The µVision helps create and test embedded applications for ARM/Cortex-M C166/C251/C51 microcontrollers.
Following memory type models,variable types,SFRs are used in 8051 based cross compiler.
Memory types
The memory model specifies which default memory type to use for following:
• function arguments
• automatic variables
• declarations with no explicit memory type specifier.
• One can specify the memory model on the Cx51 command line using SMALL,
COMPACT and LARGE directives.
Memory type specifier
Memory Type | Description |
---|---|
code | Program memory |
data | Directly addressable internal data memory |
idata | Indirectly addressable internal data memory |
bdata | bit addressable internal data memory |
xdata | External data memory |
pdata | Paged external data memory |
Variable data type specifier
Variable data type | Bits | Bytes | Value Range |
---|---|---|---|
bit | 1 | 0 to 1 | |
Signed char | 8 | 1 | -128 to +127 |
unsigned char | 8 | 1 | 0 to 255 |
signed short | 16 | 2 | -32768 to +32767 |
unsigned short | 16 | 2 | 0 to 65535 |
signed int | 16 | 2 | -32768 to +32767 |
unsigned long | 32 | 4 | 0 to 4294967295 |
float | 32 | 4 | +/- 1.17E-38 to +/-3.40E+38 |
sbit | 1 | 0 to 1 | |
sfr | 8 | 1 | 0 to 255 |
Special Function Registers(SFRs)
Intel 8051 family microprocessors specify distinct memory area for accessing SFRs.
SFRs are used mainly to control timers/counters/serial I/Os and port I/Os, peripherals.
SFRs are addressed from 0x80 to 0xFF and they can be accessed as bits, bytes, and words.
SFRs are declared in the same fashion as other C variable types.
sfr P0 = 0x80; /* Port-0, address 80h */
Generic pointers/Memory-specific Pointers
Generic pointers are declared in the same fashion as standard C pointers.
int *numptr; /* int ptr */
specify the memory area in which a generic pointer is stored by using a memory
type specifier.
int xdata *numtab; /* ptr to int(s) in xdata */
Download Evaluation development tools for all 8051 and 80251 devices from KEIL.
https://www.keil.com/download/product/
RELATED LINKS
• Microcontroller tutorial
• What is microcontroller
• 8051 Microcontroller Architecture
• Microcontroller hardware Interfacing