Monday, February 7, 2011

Weak current College】 【MCU c language Tutorial-Lesson 3: building the HEX file and minimized system】.

<br> At the start of the main elements of the C language, we'll look at how to use KEIL uVISION2 to compile build for programming the chip HEX file. HEX file format is the Intel company arranges data by address, data width bytes ., all data using a hexadecimal digit, commonly used to hold the single-chip or other processor targets program code. It saves the physical programs store target code map. General programming support this format. Let's open the first class in the first project, open .it in the same directory, find test.Uv2 document you can open the previous project. Then right-click on the figure 3-1 of 1 items folder, a pop-up menu item, select Options for Target'Target1 ', pop project .options settings window, select the project folder icon, then on the Project menu also has the same menu option. Open the project options window, go to the Output options page in Figure 3-2, as shown in Figure 1 is to select the path .to the compiled output, 2 is set to compile output generated file name, 3 is to decide whether to create a HEX file, select it can output HEX files to the specified path. Select the right? well, we recompiled it once, quickly compile .information window will display the HEX file creation to the specified path, as in Figure 3-3. So that we can use your own programmer are included with the software to read and burn onto the chip, then look at the results of the test Board ., as programmer or emulator variety specific methods to see its description, do not discuss here. <br> (Tip: first, in Figure 3-1 of 1 in the project file in a directory tree, select the object, and then click on .it to rename it, double-click the file icon to open the file. Second, in the Project drop-down menu in the bottom there is a recently edited project path is saved, you can quickly open a recently edited project.) <br .> <br> Figure 3-1 project features menu <br> <br> <br> Figure 3-2 project options window <br> <br> <br> Figure 3-3 compile information window <br> Perhaps you've .compiled file and burn onto the chip, if you have purchased or made with serial port output component of learning experimental Board, you can turn a serial port and PC serial port associated with serial debugging software or Windows HyperTerminal, the baud rate is set to 1 ., you can see a constant output "Hello World!" The typefaces. Maybe you haven't experimental Board, that here the first talk about AT89C51 minimized system, then to an instance of the Verifier minimized system is running, this minimizes the system is .also easy to self-made for experiments. Figure 3-4 is AT89C51 minimized system, however, in order to allow us to see that it is running, I added a resistor and a LED that shows its State, crystal oscillator can be used according .to their own circumstances, General experimental Board is on the used 11.0592MHz or 12MHz, using former good things can produce standard serial baud rate, the latter one machine cycle is 1 MS to do precise timing. In my own tests, noting that the VCC .is the + 5V and cannot be higher than this value, otherwise it will damage the chip, is too low it doesn't work. In 31 feet to meet high level so that we can perform on-chip program, who receives a low level .outside of the chip program memory. Here, we build a new project named OneLED to verify whether the minimized system can work (all of the routines are available in my homepage here downloaded to the Web site: http://cdle.yeah.net .or http://www.cdle.net). Procedures are as follows: <br> # Include preprocessor command <AT89X51.h> / / void main (void) / / main function name <br> {<br> / ./ This is the first a comment form <br> unsigned int a; / / Define a variable as type int. <br> / * <br> The second way of commenting <br> * / <br> Do {/ / do .composed loop while <br> for (a = 0; a <50000; a + +); / / This is a loop <br> P1_0 = 0; / / Set P1.0 mouth as low level light LED <br> for (a .= 0; a <50000; a + +); / / This is a loop <br> P1_0 = 1; / / Set a higher level P1.0 estuary, off LED <br>} <br> while (1); <br .>} <br> <br> Figure 3-4 AT89C51 minimized system <br> Here to talk about KEIL C compiler supports comment statement. A "/ /" symbol, the symbol of the statement following the statement that is considered a comment until .there is a back-of-line. The other is in the "/ *" and "* /" symbol within a comment. Comments will not be compiled as ac compiler. AC application should have a main function, the main function can call .another function, but the other function is not allowed to call the main function. Regardless of the main function in the program of that position, always be executed. Using the above knowledge compilation written OneLED program and put it to burn to just do a minimized .in the system. With electricity, initially LED is not lit (because of the power-on reset after all IO are reset 1 pin to high level), then delayed for a period of time (for (a = 0; a <50000 .; a + +) it is running), LED light, LED is off, delay, and then turn on and off. The first real small application is done, Oh, do not mind whether practical Oh. If you do not have such an .effect so you should carefully check the circuit or compiled programming steps..

No comments:

Post a Comment