An introduction to the pin functions of the external structure of the microcontroller and an overview of the usage information

Publisher:森绿企鹅Latest update time:2023-03-27 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Teaching purpose: Master the pin functions of microcontroller

2. Teaching focus: The use and differences of the P0, P1, P2, and P3 ports of the microcontroller

3. Teaching steps:

(1) Appearance of microcontroller (AT89S51)


(2) Pin function diagram of microcontroller (AT89S51)

(3) The 51 series microcontrollers 8031, 8051 and 89c51/89s51 all adopt a 40Pin packaged dual-row direct DIP structure. The picture above is their pin configuration: among the 40 pins, there are two positive power and ground wires, two clock lines for the external quartz oscillator, 4 groups of 8 bits totaling 32 I/O ports, and the interrupt port line is P3 port line reuse. Now we explain the functions of these pins:


1. Power pin

The Vcc40 pin is the positive power supply pin, and the working voltage is 5V. The working voltage of AT89LV51 is 2.7-6V, and the pin functions are the same.

GND20 ground terminal

2. External crystal pin

Pin19: Clock XTAL1 pin, Pin18: Clock XTAL2 pin,

XTAL1 is the inverting amplifier input terminal of the on-chip oscillator, and XTAL2 is the output terminal. When using an external oscillator, the external oscillation signal should be directly added to XTAL1, while XTAL2 is left floating. In internal mode, the clock generator divides the oscillation pulse by two. For example, if the crystal oscillator is 12MHz, the clock frequency is 6MHz. The frequency of the crystal oscillator can be selected from 1MHz to 24MHz. The capacitance is about 30PF.


The chip model is also AT89C51, and there is a frequency number behind it, which is available in 12, 16, 20, and 24MHz. Everyone should pay attention when purchasing and selecting. For example, AT89C51 24PC is an ordinary commercial chip with a maximum oscillation frequency of 24MHz and a 40P6 package.


3.Reset RST9

When the oscillator is running, when a high level for more than two machine cycles (24 oscillation cycles) appears on this pin, the microcontroller will be reset. As long as this pin remains high, the 51 chip will be reset cyclically. After reset, the P0-P3 ports are all set to 1 and the pins show high level, and the program counter and special function register SFR are all cleared. When the reset pin changes from high level to low level, the chip starts running the program at 0000H of ROM. The commonly used reset circuit is shown in the figure below.

The reset operation has no effect on the internal RAM. When the 8051 is powered on, the clock circuit starts to work, and a high level appears on the RESET pin for more than 24 clock cycles, and the system is initially reset. What is reset? Reset means that the microcontroller re-executes the program code.


The reset mode of 8051 can be automatic reset or manual reset, see the figure below. In addition, RESET/Vpd is also a multiplex pin. During Vcc power-down, this pin can be connected to the backup power supply to ensure that the data in the internal RAM of the microcontroller is not lost.

Input and output (I/O) pins:

Pin39-Pin32 are the P0.0-P0.7 input and output pins, called P0 port, which is an 8-bit open-drain bidirectional I/O port. There is no internal pull-up resistor. When an external pull-up resistor is connected, port P0 can drive eight LSTTL load circuits by absorbing current. Usually, an external pull-up resistor is used to drive multiple digital tubes. When accessing external programs and external data memory, the P0 port is a time-sharing converted address (lower 8 bits)/data bus, and does not require an external pull-up resistor.

Pin1-Pin8 are the input and output pins of P1.0-P1.7, called the P1 port. It is an 8-bit bidirectional I/0 port with an internal pull-up resistor. Port P1 can drive 4 LSTTL loads. Usually, no external pull-up resistor is required during use, and the light-emitting diode can be directly driven. When the port is set to 1, the internal pull-up resistor pulls the port to a high level for input.

Let’s talk about its output function now. When the microcontroller is working, we can control the pins of the microcontroller to output high level or low level by using instructions. For example: Instruction CLR means clearing.

CLR P1.0; Let the microcontroller output low level from the first pin.

The instruction SETB means setting 1.

SETB P1.0; Let the microcontroller output high level from the first pin.

How to write the instruction to make the 8th pin output low level?

Pin21-Pin28 are the input and output pins of P2.0-P2.7, called the P2 port. It is an 8-bit bidirectional I/O port with an internal pull-up resistor. The P2 port can drive 4 LSTTL loads. When the port is set to 1, the internal pull-up resistor pulls the port to a high level for input. When programming the internal Flash program memory, the upper 8 bits of address and control information are received. When accessing external programs and 16-bit external data memory, the P2 port sends the high 8-bit address. When accessing an external data memory with an 8-bit address, the contents of its pins will not change during this period.

Pin10-Pin17 are the input and output pins of P3.0-P3.7, called the P3 port. It is an 8-bit bidirectional I/O port with an internal pull-up resistor. The P2 port can drive 4 LSTTL loads. These 8 pins Also used for specialized second functions. When the port is set to 1, the internal pull-up resistor pulls the port to a high level for input.

When programming the internal Flash program memory, control information is received.

When the P1-3 port is used for input, due to the internal connected resistor, the pin that is externally pulled low will output a certain current.

In addition, the P3 port is also used for some specialized functions. Please see the table below for details.

P3 pinCombined functions
P3.0Serial communication input (RXD)
P3.1Serial communication output (TXD)
P3.2External Interrupt 0 (INT0)
P3.3External interrupt 1 (INT1)
P3.4Timer 0 input (T0)
P3.5Timer 1 input (T1)
P3.6External data memory write strobe WR
P3.7External data memory write strobe RD

What is a pull-up resistor? Simply speaking, the pull-up resistor pulls the level high, usually a 4.7-10K resistor is connected to the Vcc power supply, while the pull-down resistor pulls the level low, and the resistor is connected to the GND ground line. The specific explanation is not what is discussed here. Let’s look at other pin functions next.


5. Other control or multiplexing pins

(1) ALE/PROG 30 When accessing external memory, the output of ALE (address latch enable) is used to latch the low-order byte of the address. Even if the external memory is not accessed, the ALE terminal still outputs a pulse signal at a constant frequency (this frequency is 1/6 of the oscillator frequency). When accessing external data memory, an ALE pulse occurs. When programming the Flash memory, this pin is used to input the programming pulse PROG

(2) PSEN 29 This pin is the strobe signal output terminal of the external program memory. When the AT89C51 fetches instructions or constants from the external program memory, it outputs 2 pulses per machine cycle, which is effective twice. But when accessing external data memory, there will be no pulse output.

(3) EA/Vpp 31 External access permission end. When this pin accesses external program memory, it should be input low. To enable AT89S51 to only access external program memory (address 0000H-FFFFH), this pin must be kept low at this time. Used to apply Vpp programming voltage when programming Flash memory.

Seeing this, you should have a certain understanding of the functions of the AT89S51 pins. We will not discuss the timing of the pins in programming and verification in detail here. Under normal circumstances, we do not need to hold it. Unless you want to develop your own programmer.


Reference address:An introduction to the pin functions of the external structure of the microcontroller and an overview of the usage information

Previous article:Reset operation and reset circuit design of AT89S51 microcontroller
Next article:Decryption principle of AT89C51 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号