- The MCS-51 microcontroller has four 8-bit parallel I/O ports P0, P1, P2, and P3. Among them, P3, P2, and P1 are quasi-bidirectional ports, and P0 is a bidirectional three-state data line port. Each port is composed of a port latch, an output driver, an input buffer, etc. In addition to byte input/output, each port can also be used as an input/output individually, which is very convenient for practical applications.
- The "read-modify-write" instructions for parallel I/O ports (such as CPL P0.0, ANL P1, #0FH, etc.) actually read the contents of the corresponding port latch, modify it, and then write it back to the port latch. The reason why it is "read latch" instead of "read pin" is to avoid misreading caused by changes in the pin status due to external circuits of the pin.
-
Port P0 is a three-state bidirectional I/O port. When external ROM, RAM, etc. are required, it uses time-division multiplexing and is used as the lower 8 bits of the address bus and the 8-bit data bus through the address latch. When external ROM, RAM, etc. are not required, it is used as a general I/O port. When P0 is used as a general output port, an external pull-up resistor must be connected. When used as an input port, the latch must be written to 1 first. The output stage of port P0 has the ability to drive 8 LSTTL loads.
-
When there is no need to expand the program memory outside the MCU chip, and only 256 bytes of off-chip RAM need to be expanded, the off-chip RAM can be accessed using the "MOVX A, @Ri", "MOVX @Ri, A" type of instructions. At this time, only the lower 8 bits of the address line are used, and the P2 port is not affected by this type of instruction and can still be used as a general I/O port.
-
The corresponding port line of P3 port is in the second function, and the conditions that should be met are:
The serial I/O port is in operation (RXD, TXD). External interrupts are enabled (INT0, INT1). The timer/counter is in external counting state (T0, T1). Executes instructions to read/write external RAM (RD, WR).
Characteristics of the four working modes of timer/counter
- Mode 0 is a 13-bit counter with a maximum count value of 213=8192. The counting range is smaller than that of mode 1. It is more troublesome to calculate the initial value of the timing and prone to errors. It has no advantages over mode 1 (the original intention of the design was to be compatible with the earlier 48 series microcontrollers).
- Mode 1 is a 16-bit counter with a maximum count value of 216=65536. It has a large counting range and is suitable for applications with a large timing range.
- Mode 2 is an 8-bit counter with a maximum count value of 28=256. Its disadvantage is that the counting range is small, but its advantage is that the initial timing value can be automatically restored. It is suitable for applications that require repeated timing but the timing range is not large.
- Mode 3 is an 8-bit counter, which is only applicable to T0. T1 does not have mode 3. When T0 is in mode 3, it is split into two independent 8-bit counters TH0 and TL0: TL0 uses the original control register of T0 to form an 8-bit timer/counter; TH0 borrows TF1 and TR1 of T1 and can only count the machine cycle pulses in the machine to form another 8-bit timer. When T0 is in mode 3, T1 mode 2 is used as a serial port baud rate generator.
Calculation of timer initial value
The calculation formula for the timing time is:
If the initial value TC is set to 0, the timer timing time is the maximum. When the main frequency of the single-chip microcomputer system is 12MHz, the maximum timing time of the timer under various working modes is:
Previous article:51 MCU on-chip devices and interrupts (2)
Next article:51 instruction system (1)
Recommended ReadingLatest update time:2024-11-16 22:26
- 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)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Xunwei 4412 development board Qt_for_Android
- What toys have electrician dads made for their cute kids? Put down your phone and play with the toys your dad has customized for you.
- Comparison of entrepreneurial models of IC design companies at home and abroad
- Infineon Position2Go Development Kit Review @1. Unboxing
- 【Perf-V Review】LED Dot Matrix
- 【EVK-NINA-B400 Evaluation Kit】+Unboxing
- EEWORLD University Hall----Live Replay: Fluke's new 8.5-digit digital multimeter technology development and application
- An easy-to-understand guide to learning the msp430 microcontroller
- Basic components of a quadcopter
- [Mill MYB-YT507 development board trial experience] drive HiSpark IPC DIY Camera