Manually compile and link to generate the hex file of c51

Publisher:MindfulYogiLatest update time:2022-09-29 Source: csdn Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

This is purely a personal preference. The system UI is getting better and better now, but I still like the command line inexplicably, it's a kind of nostalgia.


Once again, this is just a personal hobby.


Although it is manually compiled, it still requires a Keil installed environment.


detailed steps:


1. Use Notepad or Notepad++ to write super simple code


For example:


#include


sbit L1 = P1^2;


void main()


{


     L1 = 0;


     while(1);


}


Save as test.c


It is best to build this source code into the keilC51BIN directory to avoid typing too many paths.


2. Enter the keil installation directory keilC51BIN in cmd


Execute the following command:


c51x test.c


lx51 test.obj TO test.abs


ohx51 test.abs   


Note that "ohx51" is the letter "o". Then check if there is a hex file in the current directory.


I tested the running light with STC89C52 successfully. I didn't try the big one, so I don't know how it works.


There are also operations for multiple files.


Source code is required. Assume there are two source code files example.c and sexample.c. Use c51x to generate obj files respectively.


The operation is:


c51x example.c


c51xsexample.c


Then use lx51. This is the key, because there are two files. There are also people on the Internet who complained about the inconvenience of Keil code editing and turned to VS2010 to write C51 code, but after configuration, they found that they could only compile one file and could not compile multiple files. This is the key. The configuration method I found on the Internet wrote the parameters of lx51 as follows:


$(ItemDir)$(ItemFileName).obj TO $(ItemDir)$(ItemFileName).abs


It seems to be OK, but it is probably because when passing parameters, not all obj file names were passed, so the problem occurred. You can try it manually. The operation is as follows:


lx51 example.obj sexample.obj To hello.abs


The last step is naturally to generate a hex file


ohx51 hello.abs


Try burning it :)


Reference post:


Problems with editing keil code in vs2010


http://bbs.csdn.net/topics/380233788?page=1

Reference address:Manually compile and link to generate the hex file of c51

Previous article:AT89C51 single chip microcomputer --1. Preliminary preparation
Next article:51 single chip microcomputer water lamp control (5 methods)

Recommended ReadingLatest update time:2024-11-22 19:56

Single chip infrared TV remote control C51 program code
//************************************************ ****************  //Name: Single-chip infrared TV remote control C51 program code() /*-------------------------------------------------------------- Description: The output of general infrared TV remote control is generated by pulse amplitude modulation of 38-40kHz
[Microcontroller]
C51 program for microcontroller to read and write 24C01
/*--------------------------24C01 IIC read and write c51 program---------------------  Many NOPs in the program are redundant. I hope readers can further simplify them, but they must be verified.  Atmel 24C01 is special and simple.  51 crystal oscillator is 11.0592MHz  ----------------------------------------------
[Microcontroller]
static, const, code keywords in C51 development
static Keyword Static can be used to modify variables in C, and can also be used to modify functions. static modifier variable Variables can exist in three places in C: the global data area, the stack, and the heap. The stack and the heap are different. int a ; int main() {   int b ;   int c* = (int *)malloc(sizeo
[Microcontroller]
[C51 code] 4*4 keyboard scan
The procedure is as follows: #include reg51.h #define uint unsigned int #define uchar unsigned char sbit key3 =P2^0; //key row detection signal sbit key2 =P2^1; sbit key1 =P2^2; sbit key0 =P2^3; sbit dis0 = P2^4;      sbit dis1 = P2^5; sbit dis2 = P2^6; sbit dis3 = P2^7; sbit dis4 = P3^3; uchar keyx,key;
[Microcontroller]
Understanding of C51 external interrupts and program calls
First, let's introduce the basic concept of C51 external interrupt Advantages of interrupts: 1. Real-time processing. The CPU is required to respond or process immediately. 2. Exception handling: If power outages, program errors, and other problems occur during operation, the CPU needs to handle the source of the faul
[Microcontroller]
Understanding of C51 external interrupts and program calls
C51 MCU C language function editing
In fact, main(), which always appears in the examples, is also a function, but it is special. It is used as the beginning of the program when compiling. With functions, C language has the advantage of modularization. Generally, for programs with more functions, each individual function will be divided into several sub
[Microcontroller]
C51 MCU C language function editing
C51 single chip microcomputer uses 74hc138 to expand the simulation circuit diagram + program of the water lamp
The C51 microcontroller uses 74hc138 to expand the water lamp program, which includes source code. The simulation circuit can be expanded to multiple LED circuits at will. The schematic diagram is as follows: The microcontroller source program is as follows: #define uint unsigned int #define uchar unsigned char vo
[Microcontroller]
C51 single chip microcomputer uses 74hc138 to expand the simulation circuit diagram + program of the water lamp
Detailed explanation of Keil C51 software usage
Section 1 Keil C51 Compiler Control Instructions  The control instructions of the C51 compiler are divided into three categories: source file control, target file control and list control.  1. Source file control  NOEXTEND: C51 source files are not allowed to use ANSI C extension functions.  DEFINE (DF): define prepro
[Microcontroller]
Latest Microcontroller Articles
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号