How to locate the subroutine segment at a fixed address in KeilC51

Publisher:sjp5035022Latest update time:2016-11-09 Source: eefocusKeywords:Keil Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
1. Function positioning:


If you want to place 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. Locating variables with initial values:
To locate a variable at an absolute position and assign an initial value, _at_ cannot be used to complete the task. Then 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 defined type is code, you can find the following under
* * * CODE MEMORY * * * : CODE xxxxH xxxxH UNIT ?CO?INITVARS then in: Project->Options for Target ...->BL51 Locate: Code, fill in: ?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.

Keywords:Keil Reference address:How to locate the subroutine segment at a fixed address in KeilC51

Previous article:LCD display c51 single chip microcomputer frequency meter
Next article:89C51 MCU Traffic Light Program

Recommended ReadingLatest update time:2024-11-16 14:45

c51: serial communication, key press to send string
1. Program Function 1. Realize the 16-bit keyboard input function of 0~f and output the key value from port P1. 2. Different key values ​​send different strings to the serial port 2. Code //Function function //1. Realize the 16-bit keyboard function from 0 to f, and display the numbers represented by the keys
[Microcontroller]
[C51 Code] Cyclic movement of advertising lights
#include /************************************************/ sbit Key=P2^0; static unsigned char p=0; void delay1ms(unsigned int count) {   int x,y;   for(x=0;x count;x++)   for(y=0;y 120;y++); } /************************************************/ void ScanKey() {      if(Key==0)    {     delay1ms(1);  
[Microcontroller]
C51 external interrupt
/*  Name: C51 external interrupt experiment  Note: I won’t talk about what interrupts are here. Let’s talk about the benefits of using interrupts in computers.  (1) Real-time processing. In computer control systems, sudden changes in the environment and parameters may require  The CPU responds or processes immediately
[Microcontroller]
Build 51 environment on keil5 (MDK5)
Prerequisite: The computer has installed the keil5 environment (MDK-Arm) first step Go to the Keil official website https://www.keil.com/download/product/ to download C51 Step 2 Just double-click the downloaded Note: It will automatically scan your keil5 environment and then install it directly into the keil5 in
[Microcontroller]
Build 51 environment on keil5 (MDK5)
C51 MCU data type range
     C51 MCU (MacroCrystal STC11L32/48/60XE) programming data type range:      As shown below:  
[Microcontroller]
LCD1602 LCD display C51 modular program + circuit diagram
The following is the circuit diagram of 51 single chip microcomputer driving 1602 LCD: The program has 3 files in total:   /********************** lcd.h header file **********************/ #ifndef _LCD_H_ #define _LCD_H_ #include reg51.h extern void lcd_init(); extern void lcd_busy(); extern void lcd_write_dat(un
[Microcontroller]
LCD1602 LCD display C51 modular program + circuit diagram
Keil code overall offset and search function
Select the code to be offset, then press the TAB key, and all selected codes will be offset backward by TAB. The number of spaces equal to TAB can be set under "Edit" - "Editor" - "C/C++ Files". If you want to go back, select the target code and press Shift+TAB. Keil's search function The motor can be called out
[Microcontroller]
Keil code overall offset and search function
Keil IAR - Cortex M3 debugging problems and solutions (2)
Recently, I have used stm32 and lm3s to make some protocol stacks, so I would like to write down some debugging experience. This article is original, so please indicate the source when reprinting it. The chip is stm32f103 stm32f107 lm3s9790 lm3s9b90, and the development environment is keil mdk 4.22 iar arm 6.30. 1
[Microcontroller]
Keil IAR - Cortex M3 debugging problems and solutions (2)
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号