About MCU IO port explanation

Publisher:DazzlingSpiritLatest update time:2021-01-31 Source: eefocusKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Introduction: When the P0 port of the 51 single-chip microcomputer works in the normal IO port mode, it is a quasi-bidirectional IO port. When it works in the second function state, it is a standard bidirectional IO port. Since the output of the bidirectional IO port requires the output of high and low levels, a complementary push-pull circuit is usually used.


Bidirectional IO port output: complementary push-pull


When the P0 port of the 51 single-chip microcomputer works in the normal IO port mode, it is a quasi-bidirectional IO port. When it works in the second functional state, it is a standard bidirectional IO port. Since the output of the bidirectional IO port requires the output of high and low levels, a complementary push-pull circuit is usually used.


In the second functional state, the 51 single-chip microcomputer P0 port adopts the complementary push-pull output mode. What is complementary push-pull? The following is its equivalent circuit diagram.

When the second function of P0 is used as output, the two switches K1 and K2 are turned on in turn. When K2 is closed and K1 is open, a high level is output, and its driving ability is very large because the resistance of the electronic switch is small (not as large as the value of the pull-up resistor). On the contrary, when K2 is opened and K1 is closed, a low level is output.


The two switches are turned on alternately and complement each other. "Pull" means "pull". The two electronic switches are respectively responsible for "pushing" and "pulling" current at the output of the IO port, so it is called complementary push-pull.


The advantages of this IO port structure are obvious, with strong driving capability, stability and reliability. The disadvantage is that it is difficult to implement. In the process of switching the output level, for example, switching from a low level to a high level, when K1 is disconnected, it is required to output a high level as quickly as possible, that is, K2 should be closed immediately; at the same time, if K1 is not disconnected, K2 is closed in advance, which is equivalent to the two switches being turned on at the same time, which will directly short-circuit and the consequences will be very serious. Therefore, it is necessary to use a circuit to control the coordinated work of the two switches.


Bidirectional IO port input: high impedance, input resistance


The output of the bidirectional IO port only requires the output of high and low levels, so it is not necessary to use a complementary push-pull circuit. The advantage of using a complementary push-pull circuit is that this circuit can also achieve high-impedance input, thereby realizing a standard bidirectional IO port.


When K1 and K2 in the figure are disconnected at the same time, the IO port can work in the high-impedance input state. What is the concept of high-impedance state?


When the IO port is in a high impedance state, it is also called a floating input state, and its level is floating and uncertain, neither high nor low. We can imagine that when the microcontroller detects the level of the IO port, it is equivalent to having something like a voltmeter in the CPU, and the internal resistance of this voltmeter is very large, such as the 100MΩ shown in the figure. Here, we can call the internal resistance of this voltmeter the input resistance of the P0.0 port at this time (it can also be roughly regarded as the output impedance, resistance is for direct current, and impedance is for alternating current. This is the knowledge of analog circuits, and I will not go into details here).

Now imagine that if you accidentally touch the P0.0 port with your hand, and because the human body itself is a conductor with a large resistance, there are many electromagnetic waves around, and there may be some very weak current on your hand, at this time, the reading of the voltmeter will change, and the level read by the microcontroller will change. The result of the high impedance state is that even a small interference from the outside world may cause the read level to change, and even if the IO port is not touched, the result of each reading may be different, because the electromagnetic waves from the outside world may interfere with the IO port. Later we will use the 51 microcontroller to do an experiment to experience the high impedance state of the P0 port.


The meaning of high impedance state, output resistance


Why is the bidirectional IO port required to be in high impedance state when inputting?


Let's assume there is a device with an equivalent circuit as shown below. When the switch is switched up and down, it will output high and low levels, which can be detected by a voltmeter. However, its driving ability is very weak and it cannot even drive an LED. The 100kΩ in the device can be called the output resistance of the device (it can also be roughly considered as the output impedance).


Let this device output low level, and then connect to the P1.0 port of 51 MCU. At this time, VCC reaches the IO port through the 10kΩ pull-up resistor, and then to the 100kΩ resistor inside the device, and is connected to GND through switch K. According to the voltage division principle, the voltage value on P1.0 is about 4.55V, so the MCU reads a high level. But the fact is that the device wants to output a low level to inform the 51 MCU. Here, the MCU pin is used as an input function, but it interferes with the output value of the external device, which is equivalent to the IO port of the MCU also outputting.


When the P0 port of the microcontroller works in the input state of the second function, or works in the input state of the ordinary IO port, and there is no external pull-up and pull-down resistor, the two internal electronic switches are disconnected and present a high impedance state to the outside. As can be seen from the figure, the output level of the device can be accurately read into the microcontroller. The reason for accurate reading is that the output resistance of the device is smaller than the input resistance of the microcontroller IO port.


Some people may say that if the resistance in the device is replaced with 1000MΩ, the microcontroller will not be able to read the voltage level accurately. However, in general, we do not need to consider such extremes. If it is an ideal high-impedance state, its input impedance should be infinite, which is a bit like a superconductor. In general, it is believed that the resistance of the wire is almost 0, and it is also believed that the input resistance of the high-impedance state is infinite.


In general, in the high-impedance state, the input resistance of the IO port is very large, and it is not easy to interfere with the output level of devices with large output resistance and weak driving capability to the IO port.


Keywords:MCU Reference address:About MCU IO port explanation

Previous article:Design of intelligent solar street light based on STC12C2051 microcontroller
Next article:Parallel interface design based on printer parallel interface

Recommended ReadingLatest update time:2024-11-16 11:44

44 common sense points in learning about microcontroller motors
  1. When the single-phase transformer is no-load, the current and the main magnetic flux are in different phases, and there is a phase angle difference aFe because there is iron consumption current. The no-load current is a peak waveform because there is a large third harmonic in it.   2. AC current flows in the arma
[Microcontroller]
51 MCU IO port composition and function introduction
1. P1 is a  quasi-bidirectional port. Each bit can be used separately. When a bit is used as an input line, the latch of the bit must be '1'; when used as an input, it can be driven by any TTL circuit and MOS circuit. Due to the internal boost circuit, it can also be driven by an open collector or open drain circuit.
[Microcontroller]
AVR MCU RTOS-AVRX Application
Introduction: AVRX is a good RTOS. Its most notable features are its small kernel and high speed. After compilation, it only takes about 500 to 700 bytes, and it has all the basic scheduling functions. Since its code is open, combined with the characteristics of different types of AVR microcontrollers, the system can
[Microcontroller]
MCU Programming Language
Preface Programming language is also known as "computer language". Compared with PC or computer, Microcontroller (microcontroller, commonly known as single-chip microcomputer) programming language is an embedded programming language. Since single-chip microcomputer programming is closely linked to hardware, its soft
[Microcontroller]
Freescale MCU AD module brief introduction (1)
The ATD module of the S12XS series MCU has a total of 27 registers, including 6 ATD conversion control registers, 2 ATD conversion status registers, 1 ATD comparison enable register, 1 ATD comparison mode register, 1 ATD conversion input enable register and 16 ATD conversion result registers (of which 7 registers ATDC
[Microcontroller]
Freescale MCU AD module brief introduction (1)
Design of flashing light using 51 single chip microcomputer
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
[Microcontroller]
Design of flashing light using 51 single chip microcomputer
The single chip computer simulates the IIC bus to communicate with the EEPROM
#include #define uchar unsigned char sbit sda=P2^0; sbit scl=P2^1; uchar a; void delay() { ;; } void start()  //开始信号 {    sda=1;   delay();   scl=1;   delay();   sda=0;   delay(); } void stop()    //停止 {   sda=0;   delay();   scl=1;   delay();   sda=1;   delay(); } void respons()  //应答 {  
[Microcontroller]
STM32 USB design microcontroller program
  First, let's take a look at the working process of USB.   When a USB device is connected to the host, the host begins to enumerate the USB device and sends a command to the USB device to obtain the relevant description information of the USB device, including device description (device descriptor), configuration d
[Microcontroller]
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号