为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

01控制一个led 灯的亮和灭(01 control the brightness and extinction of a LED lamp)

2018-04-30 11页 doc 36KB 11阅读

用户头像

is_496339

暂无简介

举报
01控制一个led 灯的亮和灭(01 control the brightness and extinction of a LED lamp)01控制一个led 灯的亮和灭(01 control the brightness and extinction of a LED lamp) 01控制一个led 灯的亮和灭(01 control the brightness and extinction of a LED lamp) The first lesson, understand the SCM and SCM control principle and the use of DX516, control of a LED lights bright and...
01控制一个led 灯的亮和灭(01 control the brightness and extinction of a LED lamp)
01控制一个led 灯的亮和灭(01 control the brightness and extinction of a LED lamp) 01控制一个led 灯的亮和灭(01 control the brightness and extinction of a LED lamp) The first lesson, understand the SCM and SCM control principle and the use of DX516, control of a LED lights bright and out Learning content in this chapter: The basic principle of SCM, how to use the DX516 simulator, and how to program a LED lamp lit out, how to enter the KEILC51uV Debugging environment, how to use single step, breakpoint, full speed, stop debugging methods Nie Xiaomeng June 2006 SCM is now becoming more and more popular, learning the upsurge of single-chip also came, many people because of work needs or personal interest needs To learn microcontroller. It can be said that master SCM development, more a rice bowl. 51 SCM has a history of more than 30 years, in China, the majority of SCM courses in Colleges and universities are 51, and 51 after so many years The development has also increased a lot of series, the function has many improvements, but also expanded a lot of branches. And domestic Bookstore SCM rack, Most of them are the 51 series. It can be foreseen that 51 SCM will only be more and more in the market, the function will only be more and more rich, predictable It's impossible to disappear for decades. As a beginner, how to access the microcontroller? What kind of knowledge and equipment do you need? In fact, knowledge doesn't need much, it's easy C language, know the basic structure of 51 SCM can be. General college graduates can quickly start, self-study of these 2 courses High school students are also qualified. Even if you have not learned the SCM course, only mastered the C language fur, through this series of tutorials, you will gradually enter the microcontroller Gate. Of course, in the process of learning, you must read more books of SCM, understand their basic structure and working style. Below to 51 as an example to understand what SCM is, what is the principle of control? In digital circuits, there are only two kinds of voltage signals, high level and low level, and 1 and 0 are recorded in figures. MCU internal The CPU, registers, buses, and so on are all operated by 1 and 0 two signals, and the data is saved by 1 or 0. Singlechip The input and output pins, that is, the IO port, also only outputs or identifies 1 and 0 two signals, that is, the high and low level. When single chip microcomputer transport One or a group of level signals to the IO port, the external device can read these signals, and the corresponding operation, which is the microcontroller external Department control. When an external or a set of level signals are sent to the IO port of the microcontroller, the microcontroller can also read these signals and analyze them This is the single chip microcomputer to read the external equipment signal. Of course, in actual operations, these signals can be very complex and must be strictly followed Specified time sequence (sequential) input output. Each device also has its own timing, and as long as strict compliance, you can control any Equipment, do whatever you can imagine. You may ask again, how can I let the microcontroller control and analyze the external equipment? The answer is the program, you can write the relevant program, and And burn them to write the microcontroller internal program space, SCM in power, will step by step in accordance with the procedures you write to execute instructions, do What do you want to do?. In the 51 standard chip, there are 32 input and output IO, divided into 4 groups, each group of 8, respectively, P0 mouth, P1 port, P2 port, P3 port. The 8 foot of P1 mouth is expressed by P1.0 to P1.7, and the others are similar. The 51 is to use these 32 ports to complete all external operations. For 51 Internal structure, if you already know, that's the best; if you don't understand, you can also put it down first, after completing several chapters of this tutorial, You'll be interested, looking for information, reading. Of course, If the user board uses current over 100mA, we recommend the use of external power supply 3. start-up When the emulator is powered, or the button on the emulator is pressed, the emulator will issue "beep", which indicates the normal start of the emulator. meanwhile The lights on the simulator flash once, which means entering the normal simulation state. 4. Simulation settings The first setting: C51 users, please add a sentence in front of your code's main () function: Char code dx516[3] _at_ 0x003b; If the above settings you did not, during the loading process, the simulator will send "beep beep" three short sound alarm, then the simulation results will be May not be right. In our routines, this phrase has been added. This sentence will not affect the work of the program, can always be retained. Second settings: Please select serial interrupt in the hardware simulation settings option and tick in the front. If the above settings you did not, during the loading process, the simulator will send "beep -" a long sound alarm, and then the simulation results will be available Can it be incorrect?. Rest settings: Select use keil Monitor-51 Driver, so that hardware emulation is possible Please select loadApplication at start to load the program directly at boot time Please select Go till main and run directly to the main function after loading In the hardware emulation settings option, select the 115200bps baud rate, all cache can not choose, or only select cache code. with Please select the correct serial number. Figure 4 Simulation Settings Well, now we can start the experiment, we open the already established project and write the good program test. By the way, I'll also learn the program tuning Trial skills. As to how to build a new project, please refer to the help file of C51, or fumble for yourself, WWW.DAXIA.COM's DX516 There are also steps to teach you how to do it for the first time..." The article can learn. Double click the lesson1.uv2 under the lessoncode01 directory, and open the interface as follows: Figure 6: program interface This interface is uV3, and it's the same as uV2. Click on the third row of second or third buttons (your compiler button position is not necessarily in that position, looking for yourself), you can see To compile the results. It shows 0errrs, 0warnings, and this is the best compile result. If you have error, you can't do the next simulation if you have There must be warning, as far as possible to eliminate, can not be eliminated, but also to confirm that the program will not be affected, the next step of simulation. In the compilation results, we can also see how many bytes have been reported by data, XDATA, code and so on. We should pay attention to whether there is one in your microcontroller So many resources, if not enough, in the future burning chips may run problems. For example, the program space of AT89C51 is 4K, XDATA if there is no outside Expansion is 0, data is 128. Beyond these limits, the program cannot run in AT89c51. Different chips have different capacities, for example SST89E516RD has a 64K program, 768 bytes of internal XDATA, and 256 bytes of data. We must have thought about that in our routines It's certainly not going to go beyond, because the DX516 emulator has the same capacity as SST89E516RD, and it's time to pay attention to it in the future. Here we deliberately write ninth lines of P10 as P11, point compilation, because there is no predefined P11, so the report error, as follows Figure: Double click on the line of the error report, and the window will jump to this line, It is convenient for you to revise. All right, now, please correct the mistake and edit it again Once the report is correct, the simulation begins below. Click the first two lines, fifth magnifying glass inside a d letter button, you can enter the simulation, the simulator should be connected in advance. Get into After simulation, you need to click the button to exit the simulation environment. Note, etc., if the program is running at full speed, the simulation environment can not be directly quit, You have to wait until the point is stopped, and then click the simulation button to quit. The point enters the simulation button, the program starts loading, the PC automatically runs to main () stops, and points to the first line of the main () function. Here is a screenshot of the simulation environment: And then introduce the button on the debug interface: Figure 5: button description After entering the simulation window, if the source code window is not the previous source code, but a window with disassembly code, the window will be turned off directly Restore to code window. The next time you go in, you go directly to the source window. Now test the single step, point one step (two single steps, step by step at the general point). You can see the lights on. The PC pointer also points to the next one Program line. Picture: the lamp is bright Just one more step, PC goes the next step, and the lights go out. Again, PC goes to the pending program, and the continuation point is still in this line. The instruction is to make the program jump to itself OK, nothing else. Generally called program hang up. The general application of the program is not suspended, usually in the main function to do a large loop, the program is as follows: Void main (void) / main program { While (1) { P11=0; / / Lighting P10=1; / / off } } Please change the main function program to the above code, and we will test the breakpoint operation in the next step. The compile results are as follows: Figure: After entering simulation Figure: You can see the following prompt window shows: "connected to Monitor-51 V.DX" behind the V.DX is already connected to the prawns , The emulator hints. V.DX is the unique identifier of prawn simulator. In line 15 double click on, you can see the program for the left there is a red box, which is to set a breakpoint, and then double-click a breakpoint. It's canceled. If the program encounters a breakpoint at full speed, it will automatically stop and analyze it. Note that after entering the simulation, and When the program is stopped, the breakpoint can be set or canceled. Graph: set breakpoint Now the point is running at full speed, you can see the program stopped at the breakpoint, and because the previous sentence has just executed the lights, so the lights are Lighted. Now set breakpoints on the fourteenth line and cancel the last breakpoint. Figure: another breakpoint is set Now running at full speed, can see the program stops at the breakpoint, and because just executed the lights, the lights were out. Okay, now the test runs at full speed and stops. Cancel the breakpoint, and then run at full speed, you can see the lights are on, but not very bright, because the program is circular, bright and alternating into OK, the bright time is not all the time. Now stop, you can see the program stopped, repeated several times at full speed and stop, you can find that each stop is not necessarily the same bit The. The lesson was over, and we learned how to light up and some basic compilation and debugging operations, The next lesson will learn how to make LED blink, And more debugging methods, and how to view the running state and set the value of the internal register. Homework: Change to second LED lights (P1.1) and finish the test in this chapter.
/
本文档为【01控制一个led 灯的亮和灭(01 control the brightness and extinction of a LED lamp)】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索