Understand the meaning of Code, RO-data, RW-data and ZI-data that appear when compiling a program in the Keil compiler

**

1: Code, RO-data, RW-data and ZI-data

**
After the STM32 microcontroller is compiled in the keil development environment, it will display:
Program Size: Code=xxxx RO-data=xxxx RW-data=xxxx ZI-data=xxxx

The compiled display window is shown in the figure:
insert image description here
What do Code, RO-data, RW-data and ZI-data mean?

Code: represents the executed code, all functions in the program;

RO-data: stands for Read Only Data, the global constant data defined in the program;

RW-data: represents initialized read and write data (Read And Write Data), global variables and static variables defined and initialized in the program;

ZI-data: Represents defined but uninitialized readable and writable data. ZI English is zero initial, which is the number of bytes of variables used in the program and initialized to 0 by the system. The keil compiler defaults that you have not initialized All variables are assigned a value of 0, and these variables are stored in RAM when the program is running.

Or we can also analyze the .map file.
The map file is located in the Listings folder in the generated project. (The project name.map file is a file generated by compiling the project. You can save the file to another directory by setting the project. By default, it is in the Listings file folder, or under the OBJ folder), you can see the display content as shown in the figure (at the bottom of the file):
insert image description here

It can be seen that after KEIL is compiled, it displays Grand Totals/ELFImage Totals in the figure, but the data actually stored in ROM does not include ZI Data (because ZI Data is not initialized, it is not necessary to provide a separate address for MDK to save its initialization data) .

  1. The size of the compiled HEX file = the value of Total ROM Size = (Code + RO Data + RW Data); Figure 2 shows that the size of the compiled HEX file is 454.82KB, which is the size of the program file actually burned into the Flash of the microcontroller . Pay attention to the Flash capacity of the single-chip microcomputer when selecting the type.


  2. The actual data size of the program running in the single-chip RAM = the value of Total RW Size = (RW Data + ZI Data); If it is greater than or equal to the compiled Total RW Size value, the program can run normally in the microcontroller.

Guess you like

Origin blog.csdn.net/m0_50862404/article/details/128946384