The 80C51 microcontroller has four P ports, P0-P3. Take P0 as an example:
To understand this problem, you need to understand the internal structure of port P0. Port P0 is connected
to the external pin by a latch through two driving field effect transistors. Reading the pin means directly reading the potential of the external pin of P0, while reading the port (latch) reads the potential of the internal latch connected to the data bus.
The two are different. Generally speaking, reading the data of P0 is reading the pin, the purpose is to obtain the state of the external circuit connected to P0. Reading the port is completed by the CPU itself when executing the following statement:
inc P0; add 1 to p0
When executing this statement, the "read-modify-write" process is adopted, first read the port data of p0, then add 1, and then send it to the latch of p0. Note that this port data is different from the pin state of p0. For example, if you write 69H to p0 in advance, the data in p0 is 69H, and the state on the pin will not enter the latch of p0 because you have not executed instructions such as MOV A, p0. It can be seen that the so-called reading port is not to read the state of p0, but it is completed by the CPU itself when executing instructions such as inc.
Reading the pin is to read the state of the p0 port. When reading the pin, pay attention to: first write FFH to p0 to disconnect its field effect tube T2 from the ground.
Because the field effect tube T2 of the p0 port is grounded at one end and connected to the external pin at the other end, it is controlled by the latch of P0. When writing 1 to the latch, it is disconnected from the ground, and when writing 0, it is connected to the ground, so when writing zero, it is always read at a low level.
Imagine that you want to read the P0 pin now. It stands to reason that P0 is connected to the external circuit, and what the external circuit is in is what you should read. However, if one end of the field effect tube T2 of the p0 port is grounded, it will pull down the potential of the p0 port, and you will always read a low level 0, so you must first write FFH to p0 to disconnect the field effect tube T2 of p0 from the ground, and then read the real state. When the external circuit is disconnected, the actual state of the p0 port (latch) is read again.
Previous article:Example of using 51 single-chip microcomputer to simulate I2C interface
Next article:Single chip microcomputer counter T0 as timing technology (timer design)
Recommended ReadingLatest update time:2024-11-23 19:04
- Popular Resources
- Popular amplifiers
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Fundamentals and Applications of Single Chip Microcomputers (Edited by Zhang Liguang and Chen Zhongxiao)
- Single chip microcomputer control technology (Li Shuping, Wang Yan, Zhu Yu, Zhang Xiaoyun)
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- The development of smartphones
- [Atria AT32WB415 series Bluetooth BLE 5.0 MCU] Light up in FreeRTOS, all codes, Github long-term update
- About the continuous reading problem of IIC
- A Simple Method for Measuring Microwave Antenna Parameters
- Want to get better service? TE customer service said: "I can"
- Is the '*' symbol in Verilog considered a multiplier?
- 【Qinheng RISC-V core CH582】Evaluation summary
- PPT of the Analog Electronic Technology Textbook edited by Yang Suxing (full)
- Cache Coherence
- Draw a process flow chart for the production of a DC regulated power supply.