

MCU I / O, the most typical application is through I / O port and 7-segment LED digital diaplay constitutes a display circuit , we used the LED display from the principles of the beginning , explaining in detail using single chip driver circuit and LED digital tube programming principles aimed at Through this programming paradigm , so that beginners understand the I / O port programming principles , intended from the replicability , on this subject. LED light-emitting principle of a little electronic technical people are well aware, we do not want to make too many presentation , 7-segment LED digital tube , the insulating material in a certain shape , using only LED combination arranged in a single "8" Type of digital control , leads to their respective electrodes , light corresponding point plan to show the figures 0-9 .
LED digital display according to the access rule were divided into yin and yang of two types , to understand these characteristics of LED , on the programming is very important because different types of digital control , in addition to their differences in the hardware circuit , the programming method Are different. Right picture is the common cathode and common anode internal digital control circuit , and their light-emitting principle is the same, but their power supply polarity is different. LED 's cathode shall be togather connected or the LED 's anode can also be connected togather . If the cathode grounded , in the corresponding section of the anode is connected to power , the paragraph that will light. Of course , LED current is usually small, generally required to limit access in the loop flow resistance .
If we are to "b" and "c" section connected to the positive power supply , the other grounded or suspended , then the "b" and "c" section of light , time, digital display will show the number " 1. " And the "a", "b", "d", "e" and "g" section are connected to the positive power supply , other pins floating , then the digital control will display "2 . " Other characters show similar principles , the reader can be self- analysis . Left the experimental circuit , we used 80C51 microcontroller, capacitor C1, C2 , and CRY1 composition of clock oscillation circuit , this part of the basic need to debug , as long as the components that would normally reliable starting oscillator . C3 , and R1 to microcomputer reset circuit , 80C51 parallel port P1.0-P1.7 directly with LED digital tube "af" pin attached to the ceiling in the indirect flow resistance R3-R10.
It is worth mentioning that , 80C51 parallel port of the output drive current is not very large , in order to have sufficient brightness LED , LED digital tube should be selected high- brightness devices . In addition, the diagram can be used 80C51 microcontroller C51 series of other , as long as they can command the system compatible with C51 normal operation , the program can be directly transplanted , for example, use low-cost Flash -based AT89C1051 or 2051 so they can repeatedly wipe ROM Was very suitable for experimental purposes . ·
Program: 01 START: ORG 0100H; program starting address
02 MAIN: MOV R0, # 00H; from "0" beginning to show
03 MOV DPTR, # TABLE; form address to send the data pointer
04 DISP: MOV A, R0; send display
05 MOVC A, @ A + ADPTR; point table address
06 MOV P1, A; data send LED
07 ACALL DELAY; delay
08 INC R0; point to the next character
09 CJNE R0, # 0AH, DISP; does not appear complete , continue
10 AJMP MAIN; the next cycle
11 DELAY: MOV R1, # 0FFH; time delay subroutine , delay time assignment
12 LOOP0: MOV R2,#0FFH
13 LOOP1: DJNZ R2,LOOP1
14 DJNZ R1,LOOP0
15 RET; subroutine return
16 TABLE: DB 0C0H; font code list
17 DB 0F9H
18 DB 0A4H
19 DB 0B0H
20 DB 99H
21 DB 92H
22 DB 82H
23 DB 0F8H
24 DB 80H
25 DB 90H
26 END; program ends