Вы находитесь на странице: 1из 3

SPJ Systems, Pune.

Phone: +91-20-27293002 SC51 Quick Start Manual for creating C applications for 8051

www.spjsystems.com

Introduction: The SC51 software package includes Assembler, Linker, Simulator and C Compiler for 8051. Besides, an IDE and other tools like Visual Code Generator (VCG) and terminal emulation cum ISP utility (SPJTerm) are also included. This document describes steps to write 8051 C programs using the SC51; and further how to use Simulator to test / debug these programs. 1. Start the SIDE51 program (i.e. the Integrated Development Environment) 2. From Project menu, select Close project. 3. From Project menu, select New Project. The Open dialog window will be displayed. Select the desired path where you wish to create this new project. (for example, C:\SPJ). CAUTION: the path and filename must not contain space or other special characters such as tab, comma, semicolon etc. In the File name field, type the name of the project, without any extension. For example, you may type PROG1. Then click on the Open button. 4. The action in the previous step will display the Project Settings dialog window. This dialog window has 3 different parts named Compiler Options, Assembler / Linker Options, and Source Files. Any of these 3 parts can be displayed by clicking on the corresponding name near the top of this dialog window. Currently, the Compiler Options will be automatically displayed. If the target micro-controller (must be a member of 8051 family) is known, you may select the appropriate Manufacturer from the list; and then select the appropriate micro-controller from the device list. If the target micro-controller is not known or if you cannot find it in the list, then you may simply select Intel as the manufacturer and 8051 or 8052 as the micro-controller. Note that when you select 8051 as the micro-controller, the Internal RAM (Bytes) selection automatically changes to 128. Similarly, when you select 8052 as the micro-controller, the Internal RAM (Bytes) selection automatically changes to 256. Select 8051 or 8052, depending on whether your target micro-controller has 128 or 256 bytes internal RAM, respectively. 5. In the same window, the Crystal frequency field is also displayed with default value as 12 MHz. If your target uses different crystal frequency, then you may change it. However, the current version of Compiler / Assembler does not actually use this value. 6. Click on Assembler / Linker Options to display that part of the dialog window. Under Program Memory (Code Memory) map: you may enter the start and end address of program memory available in your target. This program memory maybe internal (inside the micro-controller) or external. For example, if the target microcontroller is Atmel 89C52 without any external memory, then you may enter start address as 0000 and end address as 1FFF. 7. Similarly, enter start and end addresses of the XDATA (i.e. external data memory). This XDATA memory maybe on-chip or off-chip. Only start and end addresses are important, but not physical location. 8. The Compiler / Assembler automatically produces Intel HEX format file (.HEX file). If you also require the binary image file (.BIN file), then check the box labeled Generate .BIN file (ROM image).

SC51 Quick Start Manual for C Applications

Page 1 of 3

SPJ Systems, Pune. Phone: +91-20-27293002

www.spjsystems.com

9. If you plan to use In-Circuit-Emulator (ICE) for debugging, then check the box labeled Generate Absolute OMF file. This will create .AOM file, which is required by the ICE. 10. Click on Source Files to display that part of the dialog window. This window will indicate that IDE has automatically added 2 files in this new project: PROG1.C and STARTUP.ASM. The STARTUP.ASM file is automatically created by the IDE and is required for all C projects. Similarly, the IDE has automatically created an empty C file (PROG1.C). If the file PROG1.C already exists in the same path, then IDE would not create it or modify it; but it will anyway add it to the project automatically. If you wish to add more files in this project, then click on the Add file button, select the desired filename and then click on Open button. Now the Project Settings dialog will indicate that selected file has been added into the project. When all necessary files have been added to the project, click OK button to create this new project. 11. The PROG1.C file created by the IDE will be an empty file containing only the frame of main function. You may write the desired program statements in this file (or other files that you may have added to the project). When done, select Save from File menu. If you have modified more than one source files, then select Save All from File menu. 12. From the Compile menu, select Build. This will invoke the Compiler to compile the file PROG1.C; and further (assuming no errors) invoke the linker to create the .HEX and other files. If there are any errors or warnings during the process of compiling, assembling or linking, then those will be displayed in the output window (below the editor window). If there are errors, then you may correct those by making appropriate changes to the program; select Save from File menu to save the changes and then again select Build from Compile menu. Repeat this until there are no errors. 13. Now we are ready to simulate this program. To do so, simply select Simulator from the Tools menu. Simulator for 8051 is an independent program and it will be launched by this action and the current project (PROG1) will be automatically opened. The Simulator will automatically display 5 windows (clockwise, from left-top corner): Program window, Serial window, Internal RAM watch window, SFR watch window, Symbols watch window. As the names indicate, these windows display the corresponding information. So, the same program that you typed (PROG1.C) will be visible in the Program window. 14. To single step through the program, you may select Single Step from the Run menu. Pressing F7 key is also equivalent to selecting Single Step from the Run menu. When you do so, the program window will indicate that one C statement has been executed and the next statement will be highlighted. You may repeat the same to single step through the entire program. 15. While single stepping through the program, the contents of general purpose registers (R0-R7) as well SFRs will be displayed in the SFR Watch Window. The register / SFR contents can be seen changing as effect of each executed instruction. It is also possible to modify register / SFR contents by double clicking on its name. (Contents of PC can not be modified). 16. Similarly, it is possible to observe values of variables. To do so, right click in the Variables Watch Window and select Add from the pop-up menu. Select the desired variable(s) to watch and click OK button. This will display the names and values of the selected variables in the variables watch window. It is also possible to modify a variable value by double-clicking on its name. 17. The Serial window displays the activity related to 8051 serial port. i.e. any character transmitted to the serial port is displayed in this window. Similarly, it is possible to

SC51 Quick Start Manual for C Applications

Page 2 of 3

SPJ Systems, Pune. Phone: +91-20-27293002

www.spjsystems.com

simulate receiving characters. To do so, simply click inside the Serial window and type any character(s) that you wish to simulate as received. 18. When you are through with debugging, select Exit from File menu to close the Simulator. Then (if necessary) you may edit the program, build it again and start the simulator to debug again. Please note, only one instance of Simulator program should be started at any time. It is recommended to close the Simulator while making any changes to the program.

SC51 Quick Start Manual for C Applications

Page 3 of 3

Вам также может понравиться