CY AC F0 RS1 RS0 OV - P
0xFF 0x80 0x7F 0x30 0x2F 0x20 0x1F 0x18 0x17 0x10 0x0F 0x08 0x07 0x00 0x0000 0x0FFF 0x1000 0xFFFF 0x0000 0xFFFF RAM SFR
SMOD - - - GF1 GF0 PD IDL
31 19 18 9 12 13 14 15 1 2 3 4 5 6 7 8 U? EA/VP X1 X2 RESET INT0 INT1 T0 T1 P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 8051 P0.0 P0.1 P0.2 P0.3 P0.4 P0.5 P0.6 P0.7 P2.0 P2.1 P2.2 P2.3 P2.4 P2.5 P2.6 P2.7 39 38 37 36 35 34 33 32 21 22 23 24 25 26 27 28 RD 17 WR 16 PSEN 29 30 ALE/P TXD 11 RXD 10 RxD TxD INT0 INT1 T0 T1 WR RD RESET Pin ALE/PROG PSEN EA/Vpp XTAL 1,2 0 1 0 1 Address Latch Enable Program Strobe ENable External Access Enable, P0~3 A0~A15 D0~D7 Address Bus Data Bus
OSC T12 T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 T11 T12 T1 T2 ALE PSEN (1) (2) (5) (7) RD/WR PORT 2 (3) ADDRESS A15 A8 ADDRESS A15 A8 PORT 0 (3) (4) (6) (8) FLOAT A7 - A0 FLOAT INST IN A7 - A0 FLOAT INST IN FLOAT
OSC ALE T12 T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 T11 T12 T1 T2 (1) (2) PSEN RD/WR (5) (7) PORT 2 (3) ADDRESS A15 A8 PORT 0 INST IN (3) (4) (6) FLOAT A7 - A0 FLOAT DATA IN FLOAT (8) ADDRESS OR FLOAT
OSC ALE PSEN RD/WR T12 T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 T11 T12 T1 T2 (1) (5) (6) PORT 2 (2) ADDRESS A15 A8 PORT 0 INST IN (2) (3) FLOAT A7 - A0 DATA OUT FLOAT (4) ADDRESS OR FLOAT
RD WR T1 T0 INT1 INT0 TxD RxD read write Timer external input external interrupt Transmit data receive data
pin P1 = led Led <<= 1 Led = 0xf1 P10 0xfe(1111 1110) 0xfc(1111 1100) 0xfd(1111 1101) P11 0xfd(1111 1101) 0xfa(1111 1010) 0xfb(1111 1011) P12 0xfb(1111 1011) 0xf6(1111 0110) 0xf7(1111 0111) P13 0xf7(1111 0111) 0xee(1110 1110) 0xff(1111 1111)
led LED led = 0xfe #include <win51.h> #define SELECT (*(unsigned char *)(0x2fc48)) No SELECT = 0x9e P1 = led led = led << 1 led = led 0xf1 led == 0xff? Yes Led = 0xfe P1 LED LED 1bit left shift 4 1111 P13 LED Void delay (int del) { while(del--); } Void main(void) { unsigned char led=0xf2 // led on SELECT = 0x90 // led I/O do{ P1 = led; // led } delay(30000); led <<=1; // led on 1bit left shift led = 0xf1; // 4 1111 if(led==0xff) led=0xfe; } while(1); //
No A reg. LED P1 A reg. A reg. 1bit left shift A reg. OR (11110001B) A == FF? Yes P1 LED LED 1bit left shift A reg. 4 1111 P13 LED SELECT EQU 2fc48; I/O IO/SEL EqU 10011110 ; I/O ; 8051 ORG 0 SJMP START ; ; START: MOV SP, #60H ; MOV A, #IO_SEL ; MOV DPTR, #SELECT ; LATCH1 MOVX @DPTR, A MOV A, #11111110B ; LED ON LP1: MOV P1, A ; LED ON CALL DELAY ; LED ON RL A ; LED ON 1 ORL A, #0F0H ; 4 1111 CJNE A, #0FFH, LP1 ; P13 ON MOV A, #11111110B ; P13 ON LED ON SJMP LP1 ; ; LED DELAY : MOV R0, #2 ; R0 2 DELAY1 : MOV R1, #0 ; R1 0(256) DELAY2 : MOV R2, #0 ; R2 0(256) DELAY3 : NOP DJNZ R2, DELAY3 ; R2=R2-1 0 DELAY3 DJNZ R1, DELAY2 ; R1=R1-1 0 DELAY2 DJNZ R0, DELAY1 ; R0=R0-1 0 DELAY1 RET END
PC PC ~
0 / 0 1 / 1 0003H 000BH 0013H 001BH 0023H
TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0 SM0 SM1 SM2 REN B8 RB8 TI RI
EA - - ES ET1 EX1 ET0 EX0
- - - PS PT1 PX1 PT0 PX0
0 0 / 0 1 1 2 / 1 3 4
led = 0xfe led led = led << 1 led 1bit left shift SELECT = 0x9c led = led 0xf1 4 1111 P1 = led ET1 = EX1 = EA = 1 1led No 1 :, led == 0xff? Yes led = 0xfe P13 led ON While(1) P1 = led 1led
#include <win51.h> #define SELECT (*(unsigned char *)(0x2fc48)) Void main(void) { } // led INT1 I/O SELECT = 0x90 // led I/O led = 0xfe; P1 = led; // led IT1 = 1; // 1 EX1 = 1; // EA = 1; // while(1); // // 1 Void EXINT1(void) interrupt 2 { } // led 1, // 4 1111 led = (led << 1); // P13 ON, led if(led==0xff) led = 0xfe; P1 = led;
0013H. A reg. left shift led 1bit Buffer A reg. OR (11110000B) 4 1111 P1 A reg. ET1 = EX1 = EA = 1 1led No A == 0xff? Yes 1 :, A reg. (11110000B) P13 led ON SJMP$ P1 A reg. 1led
SELECT EQU 2FC48H ; latch1 address IO_SEL EQU 10011100B ; I/O ; 8051 ORG 0000H SJMP START ; 1 ORG 0013H SJMP INT_1 ; ORG 0030H START: MOV SP, #60H ; ; LED INT1 I/O MOV A, #IO_SEL MOV DPTR, #SELECT MOVX @DPTR, A MOV A, #11111110B ; LED MOV P1, A ; LED WAIT: INT_1: SKIP: ; SETB IT1 ; 1 SETB EX1 ; SETB EA ; SJMP WAIT ; ; RL A ; LED 1 ORL A, #0F0H ; 4 1111 CJNE A, #0FFH, SKIP ; P13 ON MOV A, #0FEH ; LED MOV P1, A ; 1 RETI ; END
TH0 TL0 TH1 TL1 Clock Overflow +1 TCON reg. / 0 / 1 TF0/TF1 bit set 8bit 8bit
GATE C/T M1 M0 GATE C/T M1 M0 timer1 timer0 M1 M0 0 0 0 0 1 1 1 0 2 1 1 3
TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0
led = 0xfe led led = led << 1 led 1bit left shift SELECT = 0x9e led = led 0xf1 4 1111 1 -, - 1 - GATE OFF - = 65536(0x0000) No led == 0xff? Yes led = 0xfe P13 led ON P1 = led 1led P1 = led 1led 1
#include <win51.h> // #define SELECT (*(unsigned char *)(0x2fc48)) // led // Unsigned char led; Void main(void) { // led I/O SELECT = 0x9e; led = 0xfe; // 1, 1,, // P13 ON, led TMOD = 0x10; TH1 = TL1 = 0; // 0000(65536) P1 = led; // LED ET1 = 1; // 1 TR1 = 1; // 1 } EA = 1; // while(1); // // 1 Void TIMER1(void) interrupt 3 { } // led 1, // 4 1111 led = (led << 1) 0xf1 if(led==0xff) led = 0xfe; P1 = led; // led on
Buffer A reg. left shift led 1bit 1 -, - 1 - GATE OFF - = 65536(0x0000) P1 A reg. (0FEH) A reg. OR (0F0H) No A reg. == 0FFH? Yes A A reg. (11111110) 1 4 1111 P13 led ON 1 P1 A reg. 1led
MOV TH1, #0 SELECT EQU 0FC48H ; I/O MOV TL1, #0 ; LED ON IO_SEL EQU 10011110B ; BUFFER/A,B MOV A, #11111110B ; 8051 MOV P1, A ; LED ORG 0000H ; 1 SJMP START ; SETB ET1 ; 1 ; 1 SETB TR1 ; 1 ORG 001BH SETB EA ; SJMP TIMER1 ; SJMP $ ; ; ; 1 ORG 0030H INT_1: START: RL A ; LED 1 MOV SP, #60H ; ORL A, #0F0H ; 4 1111 ; BUFFER/A,B CJNE A, #0FFH, SKIP ; P13 ON MOV A, #IO_SEL MOV A, #0FEH ; LED MOV DPTR, #SELECT SKIP: MOVX @DPTR, A MOV P1, A ; LED ON ; 1 RETI ; MOV TMOD, #10H END ; ; 1, 1,, ; 0000(65536)
SM0 SM1 SM2 REN TB8 RB8 TI RI
SM0D - - - GF1 GF0 PD IDL (SCON ) SMOD = 0 SMOD = 1 1, 3 1 /2 1 2 /4 /2 0.
PCON SMOD C/T TMOD 0, 1 MHz 12 MHz X X X X 2, 375 khz 12 MHz 1 1 X X 1,3, 62.5 khz 12 MHz 1 0 2 FFH 19.2 K 11.0592 MHz 1 0 2 FDH 9.6 K 11.0592 MHz 0 0 2 FDH 4.8 K 11.0592 MHz 0 0 2 FAH 2.4 K 11.0592 MHz 0 0 2 F4H 1.2 K 11.0592 MHz 0 0 2 E8H 137.5 11.0592 MHz 0 0 2 1DH 110 6 MHz 0 0 2 72H 110 12 MHz 0 0 1 FEEBH
REN=0 SBUF TI=1 REN=1 RI=0 RI=1 SBUF
7 6 5 4 3 2 1 0 Start Bit 8bit Data 10bit Frame Stop Bit TI=1 SBUF SBUF TI=0 TI=1 REN=1 SBUF RI=1 RI=0
Start Bit 7 6 5 4 3 2 1 0 8bit Data 11bit Frame TB8 Stop Bit TI=1 TB8=0 SBUF TB8=1 TI=0 TI=1 SBUF REN=1 RB8=0 SBUF RB8 = RB8=1 RI=0 RI=1
Start Bit 7 6 5 4 3 2 1 0 8bit Data 11bit Frame TB8 Stop Bit TI=1 TB8=0 SBUF TB8=1 TI=0 TI=1 SBUF REN=1 SBUF RB8=1 RI=1 RI=0
DIP SWITCH 1 2 3 4 5 6 7 8 ON 1 2 3 4 5 6 7 8 ON LEVEL-METER DIP SELECT = 0x9b T0 = H L H 74LS165LD(load) SELECT = 0x97 HLH T0 = 0 DIP IN DIP 74LS165 0 REN = 1 REN = 0 No No RI = 1?? TI = 1?? Yes RI=0 Select = 0x9f Yes RI TI = 0 74LS165 TI SBUF
#include <win51.h> // #define SELECT (*(unsigned char *)(0x2fc48)) // led //. Buffer Void TX_D(unsigned char buffer) { // SHIFT(74LS164) SELECT = 0x97; T0 = 0; REN = 0; // while(!ti); // TI = 0; // SBUF = buffer; // buffer T0 = 1; } //. Char RX_D(void) { // PISO(74LS165)LOAD SELECT = 0x9b; T0 = 1; // LD = H T0 = 0; // LD = L T0 = 1; // LD = H // 74LS165 REN = 1; // RI = 0; while(!ri); // RI = 0; // SELECT = 0x9f; return(sbuf); // } //, Void delay(int i) { while(i--); } Void main(void) { unsigned char dip; // 0 SM0 = 0; SM1= 0; TI = 1; // // do{ dip = RX_D(); // delay(5000); // TX_D(dip); // } while(1); }
DIP SWITCH 1 2 3 4 5 6 7 8 ON 1 2 3 4 5 6 7 8 ON LEVEL-METER DIP DIP 74LS165LD(load) Buffer2/B Buffer1/B HLH 74LS165 T0 H L H T0 H L H DIP IN 0 No REN = 1 RI = 1? RI=0 Yes? RI No / REN = 0 TI = 1? TI=0 Yes? TI A reg.
SELECT EQU 0FC48H ; LATCH1 ; 8051 ORG 0000H SJMP START ; ; ORG 0030H START : MOV SP, #60H ; ; 0 CLR SM0 CLR SM1 SETB T0 ; T0=H SETB TI ; ; LOOP : ACALL RX_D ; ACALL DELAY ; ACALL TX_D ; SJMP LOOP ;. B RX_D : MOV A, #10011011B ; BUFFER2/B MOV DPTR, #SELECT MOVX @DPTR, A ; PISO(74LS165)LOAD SETB T0 ; LD = H CLR T0 ; LD = L SETB T0 ; LD = H ; 74LS165 SETB REN ; CLR RI ; JNB RI,$ ; CLR RI ; TX_D : MOV B, SBUF ; ; BUFFER2/B MOV A, #10011111B MOV DPTR, #SELECT MOVX @DPTR, A RET ; ;. B MOV A, #10010111B MOV DPTR, #SELECT ; SHIFT(74LS164) MOVX @DPTR, A ; CLR T0 ; T0 L (74LS164 B L ) CLR REN ; JNB TI, $ ; ; CLR TI ; MOV SBUF, B ; SETB T0 ; TO L (74LS164 B H ) RET ; ;, DELAY : MOV R0, #50H DELAY1 : DJNZ R1, $ DJNZ R0, DELAY1 RET END ;
f a g b LE BI LT D C B A a b c d e f g e c X X 0 X X X X 1 1 1 1 1 1 1 8 d dp [ ] X 0 1 X X X X 0 0 0 0 0 0 0 Blank 0 1 1 0 0 0 0 1 1 1 1 1 1 0 0 0 1 1 0 0 0 1 0 1 1 0 0 0 0 1 0 1 1 0 0 1 0 1 1 0 1 1 0 1 2 B C BI LT LATCH D A GND 1 2 3 4 5 6 7 8 16 15 14 13 12 11 10 9 VCC f g a b c d e 0 1 1 0 0 1 1 1 1 1 1 0 0 1 3 0 1 1 0 1 0 0 0 1 1 0 0 1 1 4 0 1 1 0 1 0 1 1 0 1 1 0 1 1 5 0 1 1 0 1 1 0 0 0 1 1 1 1 1 6 0 1 1 0 1 1 1 1 1 1 0 0 0 0 7 0 1 1 1 0 0 0 1 1 1 1 1 1 1 8 0 1 1 1 0 0 1 1 1 1 0-0 1 1 9 0 1 1 X 0 0 0 0 0 1 0 Blank [4511 ] [4511 ]
min_h min_l sec_h sec_l 59 +1. 60 00. 1 +1. 60 00
1 0.071 10 1, count++ sec_l++ sec_l=0, sec_h++ 0.71 +1 1? 1 +1 10 10, +1 count, sec_h, sec_l, Count, min_h, min_l sec_h, sec_l 1, 1, GATE ON TH1=TL1=0 SELECT = 0xbd INT1 GATE ON 0.071. 0.71x14=0.994 INT1, sec_h=0, min_l++ min_l=0, min_h++ 6 6, +1 10 10, +1 count=sec_h=sec_l =min_h=min_l=0 ET1=TR1=EA=1 Count,, 1, min_h=0 10 6,, 1 1
#include <win8051.h> // #define SELECT (*(unsigned char*)(0x2fc48)) // 7- #define FNDH (*(unsigned char*)(0x2fc4c)) // 7- #define FNDL (*(unsigned char*)(0x2fc4d)) //, //,, unsigned char count, sec_l, sec_h, min_l, min_h; void main(void){ // 7 FNDH=0; FNDL=0; // 1, 1, GATE ON TMOD = 0x90; // 1. // 11.0592[MHz]/12 = 921600, 1/921600=1.085[us] // 1 65536 // 1.085[us] x 65536 = 0.071 // 0.071x 14 = 1 // 14 1. TH=0; TL1=0; // INT1 SELECT = 0; //,, count=sec_l=sec_h=min_l=min_h=0; // 1 ET1 = 1; TR1=1; EA = 1; while(1); // // 1 void TIMER1(void) interrupt 3{ TR1=0; // count++; // 0.71 // count14 1 if(count==14) { count=0; sec_l++; // // 4 10 if(sec_l==10) { sec_l=0; sec_h++; // 6 4 if(sec_h==6) { sec_h=0; min_l++; // 4 10 if(min_l==10) { min_l=0; min_h++; // 6 1 if(min_h==6) min_h=0; } } } } // FNDL = sec_l (sec_h << 4); FNDH = min_l (min_h << 4); } // 0.017 TH1=0; TL1=0; TR1=1; //
1 0.071 10 1 count++ 0.71 +1 1, 1, GATE ON TH1=TL1=0 INT1 GATE ON 0.071. 0.71x14=0.994 count = 0, sec++ 1? Count=0.71 1 +1 Buffer1/A count = sec = min = 0 INT1, Count,, sec=0, min++ 60 sec60, ET1=TR1=EA=1 1, min=0 60 min, TL1=TH1=0, TR1=1 1
page0 page1 page2 page7 page0 page1 page2 page7 LCD0 (64dot) LCD1 (64dot) (64dot)
0 1 1 1 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 Font Data = 0x42, 0x61, 0x51, 0x49, 0x47, 0x00, 0x00, 0x00
on/off R/W D/I 0 0 1 1 DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 0 0 0 0 1 1 1 1 1 1 ON 0 0 0 0 1 1 1 1 1 0 OFF LCD (0~63) RAM (X ) 0 0 1 0 1 1 1 (0~7) X Y 0 0 0 1 Y (0~63) Y 1 0 0 0 0 0 0 0 1 RAM 1 1 RAM RAM / Y +1. R/W : READ/WRITE, D/I : DATA/INSTRUCTION
LCD0 (LCD0_IW) LCD0 (LCD0_DW) LCD0 (LCD0_IR) LCD0 (LCD0_DR) LCD1 (LCD0_IW) LCD1 (LCD0_DW) LCD1 (LCD0_IR) LCD1 (LCD0_DR) 0xfc40 0xfc41 0xfc42 0xfc43 0xfc41 0xfc42 0xfc43 0xfc44
1Byte 1Byte 1Byte 1Byte
M 16X8 M1 16X8 LCD LCD LCD, LCD i=16?? LCD, LCD i=16??
LCD, LCD, DPTR 16X8 LCD,, DPTR 16X8. LCD. +1 LCD +1? MDA-WIN8051? M 16X8 M1 16X8 LCD