What Are the Types of Memory Areas in Keil C51?

Click the above What Are the Types of Memory Areas in Keil C51? “Chuangxue Electronics” to follow for easy learning of electronic knowledge.

Chuangxue Electronics Subscription Account

Daily updates on technical articles in the electronics industry and the latest news on microcontrollers, making it easy to learn anytime, anywhere.

Keil C51 memory areas are divided into two main types: program memory area and data memory area.

1. Program Memory Area:

To store declared data in the program memory area, you can use the keyword “code” to specify.

For example, unsigned char code i=10; indicates that i is an unsigned character type data stored in the program memory area.

2. Data Memory Area:

The data memory area is divided into internal data memory, external data memory, and special function register addressing area.

1. Internal Data Memory: You can use the keywords “data, idata, bdata” for appropriate specification.

data: Direct addressing area, the declared data storage range is the lower 128 bytes of internal RAM 0X00~0X7F.

For example, unsigned char data i=10; indicates that i is an unsigned character type data stored in the lower 128 bytes of the data memory area (RAM).

idata: Indirect addressing area, the declared data storage range is the entire internal RAM area 0X00~0XFF.

For example, unsigned char idata i=10; indicates that i is an unsigned character type data stored in the data memory area (RAM).

bdata: Bit-addressable area, with an addressing range of 0X20~0X2F.

2. External Data Memory: You can use the keywords “pdata, xdata” for specification.

pdata: Mainly used in compact mode, it can access one page (256 bytes) of external RAM, meaning that accessing data defined by pdata does not affect the output level of port P2 (when accessing certain self-extended external RAM, it does not affect I/O ports).

For example, unsigned char pdata i; indicates that i is an unsigned character type data stored in the external data memory area (RAM) (can only be within one page range), and which page to operate on can be set by other I/O ports.

xdata: Can access 64k of external data storage, with an address range of 0X0000~0XFFFF, and like pdata, accessing the chip’s own internal extended RAM does not affect I/O ports.

For example, unsigned char xdata i; indicates that i is an unsigned character type data stored in the external data memory area (RAM).

3. Special Function Register Addressing Area (SFR): The 8051 provides a 128-byte SFR addressing area, which can be byte-addressable, word-addressable, and addresses divisible by 8 can also be bit-addressable. This area is used to control timers, counters, serial ports, and other peripheral interfaces. Use the keywords “sfr, sfr16, sbit” for appropriate declaration.

For example, byte-addressing sfr P0=0x80; indicates that the P0 port address is 80H, where “=” is followed by a constant between 0X00~0XFF.

Word-addressing sfr16 T2=0XCC; specifies Timer2 port address T2L=0XCC T2H=0XCD.

Bit-addressing sbit EA=0xAF; specifies that the 0xAF bit is EA, which means interrupt enable.

> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >

How to Share to Moments

Click the top right corner What Are the Types of Memory Areas in Keil C51? and select What Are the Types of Memory Areas in Keil C51? to share to Moments.

How to Follow “Chuangxue Electronics”

1. On WeChat, click the top right corner “+” and click “Add Friends” → Search for “Chuangxue Electronics” in “Find Official Accounts” to find and follow us. 2. You can also search for WeChat ID “Chuangxue Electronics” to find and follow us.

How to View Historical Messages

Click the top right icon to enter “Account Information” → “View Historical Messages”.

Chuangxue Electronics Subscription Account

WeChat Name: Chuangxue Electronics updates various knowledge in the electronics industry daily, as well as the latest news on microcontrollers, come and start your visual feast.

Chuangxue Electronics Service Account

WeChat Name: Chuangxue Electronics is a new type of knowledge sharing platform, allowing you to view the latest articles from Chuangxue Electronics online, as well as online videos, bringing you into the world of electronic engineering technology development learning.

==> Visit www.eeskill.com to learn more!

Leave a Comment