chap4 - Chapter 4 I/O Port Programming 1 Objective We have...

This preview shows page 1 - 11 out of 57 pages.

1 Chapter 4 I/O Port Programming
2 Objective We have to understand the meanings of the physical pins of 8051, such that we understand how does 8051 exchange data with the outside world. The special pins of 8051 : Vcc…. 8051 provides 4 I/O ports : P0 : P3 transmit and receive data. How to write routines to control I/O ports. Refer to Appendix C to have a better understand of the 8051 I/O ports and their constraints. Then you can implement the system of 8051 by software.
3 Sections 4.1 Pin description of the 8051 4.2 I/O programming; bit manipulation
4 Section 4.1 Pin Description of the 8051
5 Packing Types of 8051 The 8051 family members come in different packages, such as DIP : dual in-line package : ,QFP : quad flat package : and LLC leadless chip carrier : . See Appendix H : Pages 427-429 : They all have 40 pins. Figure 4-1. 8051 Pin Diagram
6 Figure 4-1. 8051 Pin Diagram PDIP/Cerdip 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 RST (RXD)P3.0 (TXD)P3.1 (T0)P3.4 (T1)P3.5 XTAL2 XTAL1 GND (INT0)P3.2 (INT1)P3.3 (RD)P3.7 (WR)P3.6 Vcc P0.0(AD0 ) P0.1(AD1) P0.2(AD2 ) P0.3(AD3) P0.4(AD4) P0.5(AD5) P0.6(AD6) P0.7(AD7) EA/VPP ALE/PROG PSEN P2.7(A15) P2.6(A14) P2.5(A13) P2.4(A12) P2.3(A11) P2.2(A10) P2.1(A9) P2.0(A8) 8051 (8031)
7 Pins of 8051 ( 1/4 ( Vcc : pin 40 : Vcc provides supply voltage to the chip. The voltage source is +5V. GND : pin 20 : ground XTAL1 and XTAL2 : pins 19,18 : These 2 pins provide external clock. Way 1 : using a quartz crystal oscillator Way 2 : using a TTL oscillator Example 4-1 shows the relationship between XTAL and the machine cycle.
8 Pins of 8051 ( 2/4 ( RST : pin 9 : reset It is an input pin and is active high : normally low : . The high pulse must be high at least 2 machine cycles. It is a power-on reset. Upon applying a high pulse to RST, the microcontroller will reset and all values in registers will be lost. Reset values of some 8051 registers Way 1 : Power-on reset circuit Way 2 : Power-on reset with debounce
9 Pins of 8051 ( 3/4 ( /EA : pin 31 : external access There is no on-chip ROM in 8031 and 8032 . The /EA pin is connected to GND to indicate the code is stored externally. /PSEN : ALE are used for external ROM. For 8051, /EA pin is connected to Vcc. “/” means active low. /PSEN : pin 29 : program store enable This is an output pin and is connected to the OE pin of the ROM. See Chapter 14.
10

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture