51 MCU IO port input and output mode

Publisher:WiseSage123Latest update time:2016-01-10 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
       The traditional 51 microcontroller IO interface can only be used as a standard bidirectional IO interface. If it is used to drive the LED, it can only be driven by current injection or by using a transistor external drive circuit.

Current injection method: the positive pole of the LED is connected to VCC, and the negative pole is connected to the IO port. When IO is high level, the two poles of the LED are at the same level, there is no current, and the LED is off; when IO is low level, the current flows from VCC to IO, and the LED lights up. However, when you connect the positive pole of the LED to the IO interface and the negative pole to GND, and set the IO interface to a high level, the LED will light up, but the brightness is not ideal because the IO interface has insufficient pull-up capability. You can use the following method to solve this problem.

Push-pull working mode: The positive and negative poles of the LED are connected to two IO ports respectively, and then the positive IO interface is set to push-pull output, and the negative IO interface is set to standard bidirectional current sink input. The push-pull mode has strong pull-up capability and can achieve high-level driving of LEDs.

Four ways to use IO ports

    From the characteristics of the I/O port, the P0 port of the standard 51 is an open-drain structure when used as an I/O port, and a pull-up resistor is usually added in actual applications; P1, P2, and P3 are all quasi-bidirectional I/O ports with internal pull-up resistors, which can be used as both input and output. The I/O port characteristics of the LPC900 series microcontrollers are somewhat different, and they can be configured into 4 different working modes: quasi-bidirectional I/O, push-pull output, high-impedance input, and open-drain.

    Compared with the standard 51, the quasi-bidirectional I/O mode is different in internal structure, but similar in usage. For example, when it is used as an input, you must first write "1" to set it to a high level, and then you can read the level status of the pin. ! ! ! ! ! Why is it like this? See the following graphic analysis.

   The characteristic of push-pull output is that it can drive a large current regardless of whether the output is high or low. For example, when the output is high, the LED can be directly lit (with a current-limiting resistor of several hundred ohms connected in series), which is difficult to do in quasi-bidirectional I/O mode.

    The characteristic of high-impedance input mode is that it can only be used as an input, but a relatively high input impedance can be obtained, which is necessary in analog comparator and ADC applications.

    The open-drain mode is similar to the quasi-bidirectional mode, but there is no internal pull-up resistor. The advantage of the open-drain mode is good electrical compatibility. If the external pull-up resistor is connected to a 3V power supply, it can interface with a 3V logic device. If the pull-up resistor is connected to a 5V power supply, it can interface with a 5V logic device. In addition, the open-drain mode can also easily implement the "wired AND" logic function.

 

    To explain the above question, there is such a document:

 

      High impedance state is a common term in digital circuits, which refers to an output state of the circuit, which is neither a high level nor a low level. If the high impedance state is input into the next level circuit, it will have no effect on the next level circuit, just like not connected. If measured with a multimeter, it may be a high level or a low level, depending on what is connected to it.

When analyzing a circuit, the high impedance state can be understood as an open circuit. You can think of it as the output (input) resistance being very large. Its limit can be considered as floating.

      Typical applications of high impedance state:

1. In the structure of bus connection. There are multiple devices on the bus, and the devices are connected to the bus in the form of high impedance. In this way, the bus is automatically released when the device does not occupy the bus, so that other devices can obtain the right to use the bus. 
2. Most microcontroller I/Os can be set to high-impedance input when used, such as Lingyang, AVR, etc. High-impedance input can be considered as an infinite input resistance, and it is considered that the I/O has little effect on the previous stage, and does not generate current (no attenuation), and to a certain extent, it also increases the chip's ability to resist voltage shocks.


Reference address:51 MCU IO port input and output mode

Previous article:Introduction to the control pins of 51 single-chip microcomputer
Next article:51 single chip microcomputer uses digital tube to display dynamic detection results

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号