Thí nghiệm vi xử lý

Chia sẻ: Hai Dang | Ngày: | Loại File: PDF | Số trang:15

2
388
lượt xem
153
download

Thí nghiệm vi xử lý

Mô tả tài liệu
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Đọc liên tục trạng thái P1.0,P1.1,P1.2,P1.3 xuất ra P1.4,P1.5,P1.6,P1.7 Thí nghiêm tạo xung vuông 1hz không dùng timer

Chủ đề:
Lưu

Nội dung Text: Thí nghiệm vi xử lý

  1. TNVXL-ĐHBK TPHCM 2008 „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ Đọc liên tục trạng thái P1.0,P1.1,P1.2,P1.3 xuất ra P1.4,P1.5,P1.6,P1.7 „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ ORG 2000h LOOP: MOV C,P1.0 MOV P1.4, C MOV C,P1.1 MOV P1.5,C MOV C,P1.2 MOV P1.6, C MOV C,P1.3 MOV P1.7, C JMP LOOP END „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ 1 „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ ORG 2000H LAP : CPL P1.0 CALL DL SJMP LAP DL : PUSH 05H PUSH 06H PUSH 07H MOV R5,#10 L2 : MOV R6,#100 L1 : MOV R7,#250 DJNZ R7,$ DJNZ R6,L1 DJNZ R5,L2 POP 07H POP 06H POP 05H RET END „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ 1Hz ) „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ „ ORG 2000H LAP : CPL P1.0 CALL DL500 SJMP LAP DL500: MOV TMOD,#01H;TIMER 0 PUSH 07H MOV R7,#10 LOOP: MOV TH0,HIGH(-50000) MOV TL0,HIGH(-50000) SETB TR0 JNB TF0,$ CLR TR0 DJNZ R7,LOOP POP 07H RET END „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ 1
  2. TNVXL-ĐHBK TPHCM 2008 „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ ORG 2000H LJMP MAIN ORG 200BH LJMP ISRT0 MAIN: MOV TMOD,#01H;TIMER 0 PUSH 07H LOOP: MOV TH0,HIGH(-50000) MOV TL0,HIGH(-50000) SETB TR0 MOV IE,#82H SJMP $ ISRT0: DJNZ R7,THOAT MOV R7,#10 CPL P1.0 THOAT: CLR TR0 MOV TH0,HIGH(-50000) MOV TL0,HIGH(-50000) SETB TR0 RETI END „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ Thí nghiệm thay đổi tần số P1.0 bằng P1.1(tăng) và P1.2(giảm) „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ ORG 2000H MOV 31H,#100;TAO XUNG 0.1Hz MOV 32H,#20 ;TAO XUNG 0.5Hz MOV 33H,#10 ;TAO XUNG 1Hz MOV 34H,#5 ;TAO XUNG 2Hz MOV 35H,#4 ;TAO XUNG 2.5Hz MOV 36H,#2 ;TAO XUNG 5Hz MOV TMOD,#01H MOV R0,#33H LOOP: JNB P1.1,LOOP1 ;TANG TAN SO JNB P1.2,LOOP2 ;GIAM TAN SO CALL DELAY CPL P1.0 SJMP LOOP DELAY: MOV A,@R0 LAP: MOV TH0,#HIGH(-50000) MOV TL0,#LOW(-50000) SETB TR0 JNB TF0,$ CLR TF0 CLR TR0 DJNZ ACC,LAP RET LOOP1: JNB P1.1,$ INC R0 CJNE R0,#37H,TANG MOV R0,#33H TANG: SJMP LOOP 2
  3. TNVXL-ĐHBK TPHCM 2008 LOOP2: JNB P1.2,$ DEC R0 CJNE R0,#30H,GIAM MOV R0,#33H GIAM: SJMP LOOP END „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ 2s „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ ORG 2000H LAP : MOV R0,#0 LOOP : MOV DPTR,#TABLE MOV A,R0 MOVC A,@A+DPTR INC R0 CALL DL MOV DPTR,#0000H MOVX @DPTR,A CJNE R0,#0AH,LOOP SJMP LAP DL: MOV R5,#20 L2: MOV R6,#200 L1: MOV R7,#250 DJNZ R7,$ DJNZ R6,L1 DJNZ R5,L2 RET TABLE: DB 70H,71H,72H,73H,74H,75H,76H,77H,78H,79H END „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ ORG 2000H LAP: MOV R0,#0 LOOP: MOV DPTR,#TABLE MOV A,R0 MOVC A,@A+DPTR INC R0 CALL DL MOV DPTR,#0000H MOVX @DPTR,A CJNE R0,#04H,LOOP SJMP LAP DL: MOV R6,#100 L1: MOV R7,#15 DJNZ R7,$ DJNZ R6,L1 RET 3
  4. TNVXL-ĐHBK TPHCM 2008 TABLE: DB 071H, 0B2H, 0D3H, 0E4H END „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ T „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ Chuong trinh 1: ORG 2000H MOV R7,#0A0H MOV A,R7 MOV B,#10 DIV AB MOV R2,A MOV A,B ORL A,#0D0H MOV R1,A MOV A,R2 MOV B,#10 DIV AB MOV R3,A MOV A,B ORL A,#0B0H MOV R2,A MOV A,R3 ORL A,#70H MOV R3,A MOV DPTR,#0000H LAP: MOV A,R1 MOVX @DPTR,A CALL DL MOV A,R2 MOVX @DPTR,A CALL DL MOV A,R3 MOVX @DPTR,A CALL DL SJMP LAP DL: MOV R4,#15 L11: MOV R5,#100 DJNZ R5,$ DJNZ R4,L11 RET END Chuong trinh 2: ORG 2000H LOOP:MOV R7,#0A0H MOV A,R7 MOV B,#10 DIV AB MOV R0,B MOV B,#10 DIV AB ORL A,#70H ACALL GHI MOV A,B ORL A,#0B0H ACALL GHI MOV A,R0 4
  5. TNVXL-ĐHBK TPHCM 2008 ORL A,#0D0H ACALL GHI SJMP LOOP GHI:MOV DPTR,#0000H MOVX @DPTR,A RET END „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ ED. P1.0:Tăng, P1.1:Giảm „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ ORG 2000H DVI EQU 20H CHUC EQU 21H TRAM EQU 22H MOV R0,#0 MOV R1,#0 MOV DPTR,#0000 AGAIN: JB P1.0,GIAM JNB P1.0,$ INC R0 GIAM: JB P1.1 ,LOOP JNB P1.1,$ DEC R0 LOOP: MOV A,R0 MOV B,#10 DIV AB MOV DVI,B MOV B,#10 DIV AB MOV CHUC,B MOV TRAM,A MOV A,DVI ORL A,#0E0H MOVX @DPTR,A ACALL DELAY1 MOV A,CHUC ORL A,#0D0H MOVX @DPTR,A ACALL DELAY1 MOV A,TRAM ORL A,#0B0H MOVX @DPTR,A ACALL DELAY1 SJMP AGAIN DELAY1: MOV R6,#2 LOP: MOV R7,#250 DJNZ R7,$ DJNZ R6,LOP RET DELAY: MOV R5,#10 LOOP2: MOV R6,#200 LOOP1: MOV R7,#250 5
  6. TNVXL-ĐHBK TPHCM 2008 DJNZ R7,$ DJNZ R6,LOOP1 DJNZ R5,LOOP2 RET END *********************************************************************** *********************************************************************** ORG 2000H EN BIT P3.4 RS BIT P3.5 MAIN: MOV DPTR, #8000H CALL LCD_INIT MOV A,#'H' CALL WRITE_TEXT MOV A,#'e' CALL WRITE_TEXT MOV A,#'l' CALL WRITE_TEXT MOV A,#'l' CALL WRITE_TEXT MOV A,#'o' CALL WRITE_TEXT MOV A,#' ' CALL WRITE_TEXT MOV A,#'W' CALL WRITE_TEXT MOV A,#'o' CALL WRITE_TEXT MOV A,#'r' CALL WRITE_TEXT MOV A,#'l' CALL WRITE_TEXT MOV A,#'d' CALL WRITE_TEXT SJMP $ LCD_INIT: ; LCD MOV A,#38H CALL WRITE_COM MOV A,#0EH CALL WRITE_COM MOV A,#06H CALL WRITE_COM RET WAIT_LCD: DELAY: MOV R7, #100D 6
  7. TNVXL-ĐHBK TPHCM 2008 DEL1: MOV R6, #250D DJNZ R6, $ DJNZ R7, DEL1 RET RET WRITE_TEXT: ; LCD LCALL WAIT_LCD SETB RS MOVX @DPTR, A SETB EN CLR EN RET WRITE_COM: ; LCD LCALL WAIT_LCD CLR RS MOVX @DPTR, A SETB EN CLR EN RET END *********************************************************************** ********************************************************************** ORG 2000H EN BIT P3.4 RS BIT P3.5 MAIN: MOV DPTR, #TEXT CALL LCD_INIT LAP: MOVX A,@A+DPTR CALL WRITE_TEXT INC DPTR JNZ LAP SJMP $ LCD_INIT: ; LCD MOV A,#38H CALL WRITE_COM MOV A,#0EH CALL WRITE_COM MOV A,#06H CALL WRITE_COM RET WAIT_LCD: DELAY: MOV R7, #100D DEL1: MOV R6, #250D DJNZ R6, $ 7
  8. TNVXL-ĐHBK TPHCM 2008 DJNZ R7, DEL1 RET RET WRITE_TEXT: ; LCD PUSH ACC PUSH DPH PUSH DPL MOV DPTR,#8000H LCALL WAIT_LCD SETB RS MOVX @DPTR, A SETB EN CLR EN POP DPL POP DPH POP ACC RET WRITE_COM: ; LCD PUSH ACC PUSH DPH PUSH DPL MOV DPTR,#8000H LCALL WAIT_LCD CLR RS MOVX @DPTR, A SETB EN CLR EN POP DPL POP DPH POP ACC RET TEXT: “Hello World” END *********************************************************************** ********************************************************************** ORG 2000H EN BIT P3.4 CHO EQU P2 RS BIT P3.5 MAIN: MOV DPTR, #8000H CALL LCD_INIT MOV A,#'T' CALL WRITE_TEXT MOV A,#'N' CALL WRITE_TEXT MOV A,#' ' CALL WRITE_TEXT MOV A,#'V' CALL WRITE_TEXT MOV A,#'X' 8
  9. TNVXL-ĐHBK TPHCM 2008 CALL WRITE_TEXT MOV A,#'L' CALL WRITE_TEXT MOV A,#' ' CALL WRITE_TEXT CALL GOTO MOV A,#'T' CALL WRITE_TEXT MOV A,#'O' CALL WRITE_TEXT MOV A,#' ' CALL WRITE_TEXT MOV A,#'8' CALL WRITE_TEXT SJMP $ ;* LCD_INIT: chuong trinh con khoi dong LCD LCD_INIT: MOV A,#01H CALL WRITE_COM MOV A,#38H CALL WRITE_COM MOV A,#0EH CALL WRITE_COM MOV A,#06H CALL WRITE_COM RET ;* WAIT_LCD: chuong trinh con cho LCD san sang nhan lenh ;* (gia su rang sau 50ms thi LCD da thuc hien xong lenh) WAIT_LCD: DELAY: MOV R7, #10 DEL1: MOV R6, #250 DJNZ R6, $ DJNZ R7, DEL1 RET RET ;* WRITE_TEXT: chuong trinh con gui du lieu (text) ra LCD ;* tham so truyen : thanh ghi ACC WRITE_TEXT: LCALL WAIT_LCD SETB EN SETB RS MOVX @DPTR, A 9
  10. TNVXL-ĐHBK TPHCM 2008 CLR EN RET ;* WRITE_COM: chuong trinh con gui lenh (command) ra LCD ;* tham so truyen : thanh ghi ACC GOTO: LCALL WAIT_LCD MOV A,#0C0H SETB EN CLR RS MOVX @DPTR, A CLR EN RET WRITE_COM: LCALL WAIT_LCD SETB EN CLR RS MOVX @DPTR, A CLR EN RET END „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ ORG 2000H MAIN: CALL UART_INIT MOV A,#'H' CALL OUT_CHAR MOV A,#'e' CALL OUT_CHAR MOV A,#'l' CALL OUT_CHAR MOV A,#'l' CALL OUT_CHAR MOV A,#'o' CALL OUT_CHAR MOV A,#' ' CALL OUT_CHAR MOV A,#'W' CALL OUT_CHAR MOV A,#'o' CALL OUT_CHAR MOV A,#'r' CALL OUT_CHAR MOV A,#'l' CALL OUT_CHAR MOV A,#'d' CALL OUT_CHAR MOV A,#'!' CALL OUT_CHAR 10
  11. TNVXL-ĐHBK TPHCM 2008 SJMP $ UART_INIT: ; UART MOV SCON,#52H MOV TMOD,#20H MOV TH1,#-3 SETB TR1 RET OUT_CHAR: ; JNB TI, $ ; khi phat het, TI=1 CLR TI MOV SBUF, A RET IN_CHAR: ; JNB RI, $ ; khi nhan xong, RI=1 CLR RI MOV A, SBUF RET END „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ ORG 2000H EN BIT P3.4 RS BIT P3.5 MAIN: MOV DPTR, #8000H CALL LCD_INIT CALL UART_INIT LOOP: CALL IN_CHAR CALL WRITE_TEXT SJMP LOOP UART_INIT: ; UART MOV SCON,#52H MOV TMOD,#20H MOV TH1,#-3 SETB TR1 RET OUT_CHAR: ; JNB TI, $ ; khi phat het, TI=1 CLR TI MOV SBUF, A RET IN_CHAR: JNB RI, $ CLR RI MOV A, SBUF 11
  12. TNVXL-ĐHBK TPHCM 2008 RET LCD_INIT: MOV A,#38H CALL WRITE_COM MOV A,#0EH CALL WRITE_COM MOV A,#06H CALL WRITE_COM RET WAIT_LCD: DELAY: MOV R7, #100 DEL1: MOV R6, #250 DJNZ R6, $ DJNZ R7, DEL1 RET WRITE_TEXT: ; LCD CALL WAIT_LCD SETB RS MOVX @DPTR, A SETB EN CLR EN RET WRITE_COM: ; LCD CALL WAIT_LCD CLR RS MOVX @DPTR, A SETB EN CLR EN RET END „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ ORG 2000H EN BIT P3.4 RS BIT P3.5 MOV R0,#16 MOV DPTR, #8000H CALL LCD_INIT MOV TMOD,#20H MOV TH1,#-3 MOV SCON,#52H MOV A,87H SETB ACC.7 MOV 87H,A SETB TR1 LAP: CALL RECV CALL WRITE_TEXT DJNZ R0,LAP 12
  13. TNVXL-ĐHBK TPHCM 2008 MOV A,#0C0H CALL WRITE_COM SJMP LAP SENDCOM: MOV SBUF,A JNB TI,$ CLR TI RET RECV: JNB RI,$ CLR RI MOV A,SBUF RET LCD_INIT: MOV A,#01H CALL WRITE_COM MOV A,#38H CALL WRITE_COM MOV A,#0EH CALL WRITE_COM MOV A,#06H CALL WRITE_COM RET WAIT_LCD: DELAY: MOV R7, #10 DEL1: MOV R6, #250 DJNZ R6, $ DJNZ R7, DEL1 RET WRITE_TEXT: LCALL WAIT_LCD SETB EN SETB RS MOVX @DPTR, A CLR EN RET WRITE_COM: LCALL WAIT_LCD SETB EN CLR RS MOVX @DPTR, A CLR EN RET MSG: DB ' THONG MOI,HAHA!!!',0 KTHUC: SJMP $ END „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ 13
  14. TNVXL-ĐHBK TPHCM 2008 „‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟‟ ORG 2000H EN BIT P3.4 RS BIT P3.5 MOV DPTR, #8000H CALL LCD_INIT MOV TMOD,#20H MOV TH1,#-3 MOV SCON,#52H SETB TR1 LAP: CALL RECV CALL WRITE_TEXT CALL SENDCOM SJMP LAP SENDCOM: MOV SBUF,A JNB TI,$ CLR TI RET RECV: JNB RI,$ CLR RI MOV A,SBUF RET LCD_INIT: MOV A,#01H CALL WRITE_COM MOV A,#38H CALL WRITE_COM MOV A,#0EH CALL WRITE_COM MOV A,#06H CALL WRITE_COM RET WAIT_LCD: DELAY: MOV R7, #10 DEL1: MOV R6, #250 DJNZ R6, $ DJNZ R7, DEL1 RET WRITE_TEXT: LCALL WAIT_LCD SETB EN SETB RS MOVX @DPTR, A CLR EN 14
  15. TNVXL-ĐHBK TPHCM 2008 RET WRITE_COM: LCALL WAIT_LCD SETB EN CLR RS MOVX @DPTR, A CLR EN RET MSG: DB ' THONG MOI,HAHA!!!',0 KTHUC: SJMP $ END 15

CÓ THỂ BẠN MUỐN DOWNLOAD

Đồng bộ tài khoản