Design of flashing light using 51 single chip microcomputer

Publisher:中和子Latest update time:2021-01-25 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Introduction: 51 MCU is a general term for all MCUs compatible with Intel 8031 ​​instruction system. The ancestor of this series of MCUs is Intel's 8031 ​​MCU. Later, with the development of Flash ROM technology, 8031 ​​MCU has made great progress and become one of the most widely used 8-bit MCUs.


1. Circuit Diagram

The current that needs to flow through a diode to light up is generally 3mA~10mA, and the voltage drop across the diode is 1.6V~1.7V.


2. Light up the diode:


(1) Bit operation: sbit led0=P0^0; led0=0; //Assignment of a single bit


(2) Bus operation: P0=0xfe; //11111110 The entire 8-bit pin is assigned a value


3. Software simulation:

Click the d icon on the toolbar, double-click a line to set a breakpoint; if you want to use software simulation to view the execution time of a statement, you must set the crystal frequency to the same frequency as the MCU in Options for target -> target -> Xtal (MHz). (Machine cycle = 12* crystal cycle = 12* system clock cycle, the higher the crystal frequency, the faster the MCU executes. The frequency of 11.0592M is generally used for serial communication between MCUs and MCUs or hosts)


4. When the EA pin 31 of the 51 single-chip microcomputer is connected to a high level, instructions are read from the on-chip memory for execution; when the level is low, the off-chip memory is read.


5. In the 51 single-chip microcomputer, P1, P2, and P3 all have pull-up resistors, but P0 does not. Therefore, if you want to use P0 as a normal I/O port, you need to add a pull-up resistor (such as a resistor array).


6. After some compilers are completed, they will automatically loop the program you wrote in an infinite loop. If you want the program to stop after a certain statement, just add "while (1);" after the statement.


7. #include the function _crol(k, 1) for shifting /*Assume k is 11111110, after the function is executed, k is 11111101*/.


8. After the 51 microcontroller is powered on, the default I/O port state is high level.


Reference address:Design of flashing light using 51 single chip microcomputer

Previous article:Capacitive sensor measurement system module circuit design square wave generation circuit
Next article:51 MCU IO port input and output mode

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号