Question: The book says that to measure the pin level of port P1, the corresponding pin needs to be set first. For example, to measure port P1.0:
ORL P1, #01H ; first set
MOV C, P1.0 ; then read the interface
Since the data given to the P1 port can generate a level, what is the point of setting it first and then measuring it? Isn't it obvious that it has become a high level? How can we measure it?
Satisfactory answer:
This is determined by the internal structure of the pin.
When the pin of the microcontroller outputs a low level, there is a strong pull-down circuit inside the pin, which can make the pin output a low level stably, and the pin can withstand a sink current of up to 20mA (different models vary);
when the pin of the microcontroller outputs a high level, the pull-up circuit inside the pin has little effect, although it can make the pin output a high level, but if the external circuit pulls the pin's potential down, it will be read back to 0 when reading.
This is the so-called "quasi-bidirectional port".
To use the pin input, you should first output 1 to put the pin in a weak pull-up input state.
Previous article:P1 external 4x4 keyboard reverse scanning
Next article:51 MCU C language: irregular matrix keyboard
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- [Review of Arteli Development Board AT32F421] 2. Use of peripheral ERTC
- [Mil MYD-YA15XC-T Review] + Unboxing
- How to choose between different chips in TI's Sub-1GHz product line?
- CircuitPython Electronic Chain Bracelet
- "C Programming Magic Book: Based on C11 Standard"
- [Project Source Code] 3 methods to display state machine names in Modelsim simulation based on FPGA
- Temperature sensor + I2C + serial port + PC host (pyserial) example
- MSP430G2553 internal ADC principle and routine description
- Types of PCB substrates
- What is the difference between an AD schematic and a schematic library?