1. Function location:
If you want to put the function
int BIN2HEX(int xx)
{
...
}
in the C source file tools.c at 0x1000 in CODE MEMORY, compile the project first, then open the M51 file of the project, and find the name of the function to be located under the line
* * * CODE MEMORY * * * , which should be in the form of: CODE xxxxH xxxxH UNIT ?PR?_BCD2HEX?TOOLS Then fill in the following content in: Project->Options for Target ...->BL51 Locate: Code : ?PR?_BCD2HEX?TOOLS(0x1000) Build again, and you will find that the function has been placed at 0x1000 in CODE MEMORY in M51. 2. Variable location with initial value: To locate a variable at an absolute position and assign an initial value, use _at_ If it cannot be completed, do the following: Create a new file in the project, such as InitVars.c, and assign an initial value to the variable to be processed (assuming it is a code variable ): char code myVer = {"COPYRIGHT 2001-11"}; Then add the file to the project, compile, open the M51 file, if the definition is code type, you can find it under * * * CODE MEMORY * * * : CODE xxxxH xxxxH UNIT ?CO?INITVARS Then fill in: Project->Options for Target ...->BL51 Locate: Code : ?CO?INITVARS(0x200) and compile again. Correspondingly, if it is an xdata variable, write in InitVars.c: char xdata myVer = {"COPYRIGHT 2001-11"}; then add the file to the project, compile, open the M51 file, and under * * * XDATA MEMORY * * * you can find: XDATA xxxxH xxxxH UNIT ?XD?INITVARS Then fill in: ?XD?INITVARS(0x200) in: Project->Options for Target ...->BL51 Locate: Xdata and compile again. Correspondingly, if the variables defined are data/idata, then handle them accordingly. 3. If there are multiple variables or functions to be located at absolute addresses, they should be arranged in order from low to high addresses.
Reference address:How to locate a subroutine segment at a fixed address?
If you want to put the function
int BIN2HEX(int xx)
{
...
}
in the C source file tools.c at 0x1000 in CODE MEMORY, compile the project first, then open the M51 file of the project, and find the name of the function to be located under the line
* * * CODE MEMORY * * * , which should be in the form of: CODE xxxxH xxxxH UNIT ?PR?_BCD2HEX?TOOLS Then fill in the following content in: Project->Options for Target ...->BL51 Locate: Code : ?PR?_BCD2HEX?TOOLS(0x1000) Build again, and you will find that the function has been placed at 0x1000 in CODE MEMORY in M51. 2. Variable location with initial value: To locate a variable at an absolute position and assign an initial value, use _at_ If it cannot be completed, do the following: Create a new file in the project, such as InitVars.c, and assign an initial value to the variable to be processed (assuming it is a code variable ): char code myVer = {"COPYRIGHT 2001-11"}; Then add the file to the project, compile, open the M51 file, if the definition is code type, you can find it under * * * CODE MEMORY * * * : CODE xxxxH xxxxH UNIT ?CO?INITVARS Then fill in: Project->Options for Target ...->BL51 Locate: Code : ?CO?INITVARS(0x200) and compile again. Correspondingly, if it is an xdata variable, write in InitVars.c: char xdata myVer = {"COPYRIGHT 2001-11"}; then add the file to the project, compile, open the M51 file, and under * * * XDATA MEMORY * * * you can find: XDATA xxxxH xxxxH UNIT ?XD?INITVARS Then fill in: ?XD?INITVARS(0x200) in: Project->Options for Target ...->BL51 Locate: Xdata and compile again. Correspondingly, if the variables defined are data/idata, then handle them accordingly. 3. If there are multiple variables or functions to be located at absolute addresses, they should be arranged in order from low to high addresses.
Previous article:ds1868c driver
Next article:Parallel I/O Port Programming Example
- Popular Resources
- Popular amplifiers
Latest Microcontroller Articles
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
MoreDaily News
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Three steps to govern hybrid multicloud environments
- Three steps to govern hybrid multicloud environments
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Melexis launches ultra-low power automotive contactless micro-power switch chip
Guess you like
- TI mmWave sensor carrier card platform
- 51 single chip digital tube serial communication
- Is it possible to use gallium nitride?
- Smoother than oil, make an electric ice pot with hard disk platters and breast pump
- [Third Batch of Shortlist] GigaDevice GD32L233 Review Activity
- [Practice Together in 2021] Looking Back at 2020 and Looking Forward to 2021
- Matter Development Guide (Part 2): Building a Matter Application
- Year-end feedback: EEWorld's 2018 Most Influential Netizens' Choice
- [Qinheng RISC-V core CH582] 1- Unboxing and use
- Single-chip microcomputer example of single light flashing