From the data storage type, the 8051 series has on-chip, off-chip program memory, on-chip, off-chip data memory, the on-chip program memory is also divided into direct addressing area and indirect addressing type, respectively, corresponding to code, data, XData, idata, and according to the characteristics of the 51 series pdata type, Using different memory will make program execution more efficient, and when writing a C51 program, it is best to specify the storage type of the variable, which will help improve program execution efficiency (this problem will be explained later). and ansi-c slightly different, it only sub-SAMLL, COMPACT, large mode, a variety of different models corresponding to the actual hardware system, there will be different compilation results.
Differences in Data,idata,xdata,pdata in the 51 series:
Data: Fixed refers to the front 0x00-0x7f 128 ram, can be directly read and write with ACC, the fastest, the resulting code is minimal.
Idata: Fixed refers to the previous 0X00-0XFF 256 RAM, where the first 128 and data 128 are identical, only because of the way the access is different. Idata is accessed in a pointer-like manner in C. The statements in the assembly are: Mox ACC, @Rx. (Unimportant supplement: C-Idata do a good job of pointer-type access)
XData: External extended RAM, generally referred to as external 0x0000-0xffff space, accessed with dptr.
pdata: Low 256 bytes of external extended RAM, address reads and writes on A0-A7, with Movx ACC, @Rx Read and write. This is more special, and C51 seems to have a bug, it is recommended to use less. But also has his merit, the concrete usage belongs to the intermediate question, here does not mention.
Microcontroller C language unsigned char code table[] code is what role?
The role of code is to tell the microcontroller, I define the data to be placed in the ROM (program store) inside, can not be changed after writing, in fact, is quite with the assembly inside the address MOVX (as if), because there is no way to describe in C in detail whether the ROM or RAM (register), So in the software added this statement to replace the assembly instructions, and the corresponding data is stored in RAM meaning.
The program can be easily divided into code (program) area, and data area, the code area is not changed when running, the data area to put the global variables and temporary variables, is to constantly change, the CPU from the code area read instructions, the data area to perform operations processing, So the code area stored in what medium is not important, like the previous computer program stored on the card, the code area can also be placed in the ROM, also can be placed in RAM, also can be placed in flash (but the speed is much slower, the main read flash than read RAM time), So the general practice is to put the program in Flash, and then load into the RAM to run, the data area there is no choice, it must be placed in RAM, placed in the ROM can not be changed.
How does bdata use it?
If the program requires 8 or more bit variables, if you want to give 8 variables at a time to assign value, it is not convenient, (for example, say it's convenient, want to know more in-depth understanding in the application itself) and can not define a bit array, there is only one method
Char bdata MODE;
Sbit mode_7 = mode^7;
Sbit mode_6 = mode^6;
Sbit mode_5 = mode^5;
Sbit mode_4 = mode^4;
Sbit mode_3 = mode^3;
Sbit mode_2 = mode^2;
Sbit mode_1 = mode^1;
Sbit mode_0 = mode^0;
A 8 bit variable mode_n is defined.
This is the special data type that defines the statement, KEILC. Remember, it must be sbit.
Cannot bit mode_0 = mode^0;
Assignment statements If all these C languages are treated as XOR or arithmetic
Turn: Data,idata,xdata,pdata,code in C language of single-chip microcomputer