In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to use C language to access the core code of memory in 51 single-chip microcomputer, many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.
What is C language? C language is a process-oriented and abstract general programming language, which is widely used in low-level development. C language can be used to compile and process low-level memory in a simple way.
Use C language to access memory 1 in 51 single-chip microcomputer. Header file
In Keil C51 project # include, you can directly use CBYTE, XBYTE, DBYTE, PBYTE
Some of the contents of absacc.h are as follows:
# ifndef _ _ ABSACC_H__#define _ ABSACC_H__#define CBYTE ((unsigned char volatile code *) 0) # define DBYTE ((unsigned char volatile data *) 0) # if! defined (_ _ CX2__) # define PBYTE ((unsigned char volatile pdata *) 0) # endif#define XBYTE ((unsigned char volatile xdata *) 0) # define CWORD ((unsigned int volatile code *) 0) # define DWORD ((unsigned int volatile data *) 0) # if! defined (_ _ CX2__) # define PWORD ((unsigned int volatile pdata *) 0) # endif#define XWORD ((unsigned int volatile xdata *) 0)
Code data pdata xdata are all memory types, which are described in more detail in the next section, where T is used instead:
Unsigned char volatile T * is the pointer type to the number of unsigned integers in memory T
((unsigned char volatile T *) 0) cast 0
2.code data pdata xdata
Code data pdata xdata are all memory types.
Code: used to store constants and functions, accessed using a 16-bit address, and can be located either on or off the chip
ROMdata: used to store variables, using an 8-bit address, located on an on-chip RAMp
Data: used to store variables, using an 8-bit address, located on an off-chip RAMx
Data: used to store variables, using a 16-bit address, located on an off-chip RAM
The difference between 3.CBYTE, DBYTE, PBYTE and XBYTE
Note: the following storage address ranges all refer to the maximum range that can be accessed in theory, and the specific operation needs to be adjusted according to the memory size.
The differences between the four parts of this section can be drawn from the differences in memory types:
CBYTE
CBYTE is used to access the code memory, that is, the ROM part.
Rval = CBYTE [adress]; / / access to the contents of the code store
The code memory address (adress) range is 0X0000--0xFFFF and the size is 16K.
DBYTE
DBYTE is used to access the on-chip data memory, that is, the on-chip RAM part.
DBYTE [adress] = 0XFB; / / write data rval = DBYTE [adress]; / / read data
The range of on-chip memory address (adress) is 0x00--0xFF and the size is 256byte.
XBYTE
XBYTE is used to access the off-chip data memory, that is, the off-chip RAM part, but the XBYTE can only read the data and not write the data to the off-chip RAM.
Rval = XBYTE [adress]; / / read the data
The following statement can be used for writing off-chip data storage:
Char xdata x1 _ at_ 0x30; / / x1 is a char global variable whose address is located in the Xdata area address 0x30 x1 = 0x01; / / assign a value to the address of the off-chip memory
The address range is 0x0000--0xFFFF and the size is 16K.
PBYTE
PBYTE is also used to access the extended ram, but only the first 256 bytes can be accessed.
4.CWORD, XWORD, DWORD and PWORD
The four described in the previous section are single-byte access, and the corresponding double-byte access uses CWORD, DWORD, XWORD, and PWORD.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.