Thông báo

Collapse
No announcement yet.

Giao tiếp với nhiều ma trận (matrix 8x8)

Collapse
X
 
  • Lọc
  • Giờ
  • Show
Clear All
new posts

  • #16
    Em có một chương trình này đao được trên mạng nhưng đó chỉ là thuật toán viết cho 5 con ma trận thôi kính mong sự giúp đỡ của các sư huỵnh , và toàn thể các bạn giúp đỡ .em xin chân thành cảm ơn !

    Comment


    • #17
      chương trình như sau:CODE:



      $MOD51



      HANG DATA P2 ;HANG PORT2 TICH CUC MUC THAP

      COT DATA P3 ;COT PORT3 TICH CUC MUC CAO

      SELECT0 BIT P0.0 ;CAC BIT CHON LED TICH CUC

      SELECT1 BIT P0.1

      SELECT2 BIT P0.2

      SELECT3 BIT P0.3

      SELECT4 BIT P0.4

      CHONCT BIT P0.7 ;BIT CHON CHUONG TRINH NAO SE DUOC THUC THI

      START BIT P0.6 ;BIT CHO CHAY CHUONG TRINH DUOC CHON

      ;----------------------------------------------------------- ---

      STARTS:

      MOV P2,#0FFH ;XOA HANG

      MOV P3,#00H ;XOA COT

      MOV R0,#00H ;NAP GIA TRI DAU TIEN CHO R0

      MAIN: ;CHUONG TRINH CHINH,KIEM TRA VA CHO THUC

      ;HIEN CHUONG TRINH DUOC NGUOI SU DUNG CHON



      CJNE R0,#00,HS1

      LCALL SO0

      HS1: CJNE R0,#02,HS2

      LCALL SO1

      HS2: CJNE R0,#04,HS3

      LCALL SO2

      HS3: CJNE R0,#06,HS4

      LCALL SO3

      HS4: CJNE R0,#08,KT0

      LCALL SO4



      KT0: JNB START,SELECT ;NHAY NEU BIT START DUOC NHAN

      ;DEN BANG CHON CHUONG TRINH (SELECT)

      LJMP KT1 ;NEU BIT START CHUA DUOC NHAN ,

      ;KIEM TRA TIEP BIT CHONCT

      KT1: JNB CHONCT,TANGR0 ;NEU BIT CHONCT DUOC NHAN,

      ;TANG R0 DE CHON CT TUONG UNG

      LJMP MAIN ;QUAY LAI DE KIEM TRA TU DAU



      TANGR0:

      INC R0 ;TANG R0 THEM 2,VI LENH AJMP

      ; TRONG BANG NHAY TABLE CHIEM 2 BYTE

      INC R0

      LCALL DELAY ;CHONG NHIEU ,TRONG TRUONG HOP

      ; GIU NUT NHAN LAU HON CHU KI KIEM TRA

      LJMP MAIN ;QUAY LAI KIEM TRA TU DAU



      SELECT: ;NHAY DEN CAC CHUONG TRINH TUONG UNG

      MOV DPTR,#TABLE

      MOV A,R0

      JMP @A+DPTR ;NHAY DEN CHUONG TRINH DUOC CHON

      ; (DO GIA TRI R0 LUC NAY)





      TABLE: ;BANG CHON CHUONG TRINH

      AJMP PR0

      AJMP PR1

      AJMP PR2

      AJMP PR3

      AJMP PR4

      ;----------------------------------------------------------- -------

      ;CAC CHUONG TRINH CON HIEN THI SO

      ;----------------------------------------------------------- -------

      SO0:

      CLR SELECT0 ;CHO LED 0 TICH CUC

      MOV DPTR,#MASO0

      LCALL SCAN1MT

      RET

      SO1:

      CLR SELECT0 ;CHO LED 0 TICH CUC

      MOV DPTR,#MASO1

      LCALL SCAN1MT

      RET

      SO2:

      CLR SELECT0 ;CHO LED 0 TICH CUC

      MOV DPTR,#MASO2

      LCALL SCAN1MT

      RET

      SO3:

      CLR SELECT0 ;CHO LED 0 TICH CUC

      MOV DPTR,#MASO3

      LCALL SCAN1MT

      RET

      SO4:

      CLR SELECT0 ;CHO LED 0 TICH CUC

      SETB SELECT1

      MOV DPTR,#MASO4

      LCALL SCAN1MT

      RET

      ;----------------------------------------------------------- --------

      ;CAC CHUONG TRINH CON DE LUA CHON

      ;----------------------------------------------------------- --------

      PR0:

      LCALL CT0

      LJMP PR0

      PR1:

      LCALL CT1

      LJMP PR1

      PR2:

      LCALL CT2

      LJMP PR2

      PR3: ;CHUA DUNG

      LJMP PR3

      PR4: ;CHUA DUNG

      LJMP PR4

      ;----------------------------------------------------------- --------

      ;CAC CHUONG TRINH CHAY CHU

      ;----------------------------------------------------------- --------



      CT0: ;CHAY DOAN CHU "HAPPY NEW YEAR 2008".

      MOV DPTR,#MAHIENTHI2

      LAP2:

      LCALL SCAN5MT

      INC DPTR

      MOV A,DPL

      CJNE A,#LOW(MAHIENTHI2+144),LAP2

      RET

      ;----------------------------------------------------------

      CT1: ;HIEN THI "DIEN TU"

      MOV DPTR,#DIENTU

      LCALL SCAN5MT

      RET

      ;-----------------------------------------------------------



      CT2: ;HIEN THI "X CUONG".



      MOV DPTR,#CUONG

      LCALL SCAN5MT

      RET

      ;----------------------------------------------------------

      ;CAC CHUONG TRINH QUET MA TRAN

      ;----------------------------------------------------------

      SCAN1MT: ;CHUONG TRINH QUET MOT MA TRAN

      PUSH 00H

      PUSH 01H

      PUSH ACC

      MOV R0,#00H

      MOV R1,#80H ;R1 DUNG DE QUET COT(10000000B)

      SCAN:

      MOV A,R0

      MOVC A,@A+DPTR ;LAY MA HIEN THI

      MOV HANG,A ;DUA DU LIEU RA HANG

      MOV COT,R1 ;QUET COT

      LCALL DELAY2

      MOV COT,#00H ;CHONG LEM

      INC R0 ;TANG R0 DE LAY DU LIEU KE

      MOV A,R1 ;DICH PHAI R1,DE QUET COT KE

      RR A

      MOV R1,A

      CJNE R0,#08,SCAN ;KIEM TRA QUET DU 8 COT

      POP ACC

      POP 01H

      POP 00H

      RET



      ;---------------------------------------------------------

      ;CHUONG TRINH QUET 5 MA TRAN.



      SCAN5MT:

      PUSH 00H

      PUSH 01H

      PUSH 03H

      PUSH ACC

      MOV R0,#00H ;OFFSET LAY MA HIEN THI

      MOV R3,#11101111B ;DUNG DE CHON MA TRAN TICH CUC,

      ;TICH CUC LED 4 DAU TIEN

      SCAN2: ;NAP LAI SAU KHI DA QUET XONG 1 MA TRAN

      MOV R1,#80H ;QUET COT

      MOV P0,R3 ;TICH CUC MA TRAN

      SCAN1:

      MOV A,R0

      MOVC A,@A+DPTR

      MOV HANG,A

      MOV COT,R1

      LCALL DELAY3

      MOV COT,#00H ;CHONG LEM

      INC R0 ;TANG R0 DE LAY MA HIEN THI KE

      MOV A,R1 ;DICH PHAI R1 DE QUET COT KE

      RR A

      MOV R1,A

      CJNE R1,#80H,SCAN1;NHAY KHI CHUA QUET HET 8 COT

      MOV A,R3 ;DICH PHAI R3 DE TICH CUC MA TRAN TIEP THEO

      RR A

      MOV R3,A

      CJNE R3,#01111111B,SCAN2 ;NHAY KHI CHUA HET 5 MA TRAN

      POP ACC

      POP 03H

      POP 01H

      POP 00H

      RET

      ;----------------------------------------------------------

      ;CAC CHUONG TRINH DELAY

      ;----------------------------------------------------------

      DELAY: ;CHUONG TRINH DELAY 0.5S

      PUSH 00H

      MOV TMOD,#01H

      MOV R0,#200

      LOOP:

      MOV TH0,#0F6H

      MOV TL0,#03CH

      SETB TR0

      JNB TF0,$

      CLR TR0

      CLR TF0

      DJNZ R0,LOOP

      POP 00H

      RET



      ;----------------------------------------------------------

      DELAY2: ;CHUONG TRINH DELAY 2.5MS

      PUSH 00H

      PUSH 01H

      MOV R1,#5

      LOOP2:

      MOV R0,#250

      DJNZ R0,$

      DJNZ R1,LOOP2

      POP 01H

      POP 00H

      RET

      ;----------------------------------------------------------

      DELAY3: ;CHUONG TRINH DELAY 1.25 MS

      PUSH 00H

      PUSH 01H

      MOV R1,#3

      LOOP3:

      MOV R0,#210

      DJNZ R0,$

      DJNZ R1,LOOP3

      POP 01H

      POP 00H

      RET

      ;----------------------------------------------------------

      ;BANG MA DU LIEU HIEN THI

      ;----------------------------------------------------------

      MASO0:

      DB 0FFH,0FFH,0C1H,0BEH,0BEH,0BEH,0C1H,0FFH ;SO 0

      MASO1:

      DB 0FFH,0FFH,0EEH,0DEH,080H,0FEH,0FEH,0FFH ;SO 1

      MASO2:

      DB 0FFH,0FFH,0D8H,0B6H,0B6H,0B6H,0CEH,0FFH ;SO 2

      MASO3:

      DB 0FFH,0FFH,0DDH,0B6H,0B6H,0B6H,0C9H,0FFH ;SO 3

      MASO4:

      DB 0FFH,0FFH,0E3H,0DBH,0BBH,0FBH,080H,0FFH ;SO 4





      CUONG:

      DB 0FFH,09CH,0EBH,0F7H,0EBH,09CH,0FFH,0FFH,0FFH ; CHU X

      DB 0C1H,0BEH,0BEH,0BEH,0DDH,0FFH ; CHU C

      DB 081H,0FEH,0FEH,0FEH,081H,0FFH ; CHU U

      DB 0C1H,0BEH,0BEH,0BEH,0C1H,0FFH ; CHU O

      DB 080H,0DFH,0EFH,0F7H,080H,0FFH ; CHU N

      DB 0C1H,0BEH,0B6H,0B6H,0D1H,0FFH,0FFH ; CHU G

      DIENTU:



      DB 0FFH,080H,0BEH,0BEH,0BEH,0C1H,0FFH ; CHU D

      DB 0BEH,0BEH,080H,0BEH,0BEH,0FFH ; CHU I

      DB 080H,0B6H,0B6H,0B6H,0B6H,0FFH ; CHU E

      DB 080H,0DFH,0EFH,0F7H,080H,0FFH ; CHU N

      DB 0FFH,0FFH,0BFH,0BFH,080H,0BFH,0BFH,0FFH ; CHU T

      DB 081H,0FEH,0FEH,0FEH,081H,0FFH,0FFH; CHU U



      MAHIENTHI2:

      DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH

      DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH

      DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH

      DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH

      DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH

      DB 0FFH,0FFH,0FFH,080H,0F7H,0F7H,0F7H,080H,0FFH ; CHU H

      DB 0E0H,0DBH,0BBH,0DBH,0E0H,0FFH ; CHU A

      DB 080H,0B7H,0B7H,0B7H,0CFH,0FFH ; CHU P

      DB 080H,0B7H,0B7H,0B7H,0CFH,0FFH ; CHU P

      DB 09FH,0EFH,0F0H,0EFH,09FH,0FFH ; CHU Y

      DB 0FFH,0FFH,080H,0DFH,0EFH,0F7H,080H,0FFH ; CHU N

      DB 080H,0B6H,0B6H,0B6H,0B6H,0FFH ; CHU E

      DB 080H,0FDH,0FBH,0FDH,080H,0FFH ; CHU W

      DB 0FFH,0FFH,09FH,0EFH,0F0H,0EFH,09FH,0FFH ; CHU Y

      DB 080H,0B6H,0B6H,0B6H,0B6H,0FFH ; CHU E

      DB 0E0H,0DBH,0BBH,0DBH,0E0H,0FFH ; CHU A

      DB 080H,0B7H,0B3H,0B5H,0CEH,0FFH ; CHU R

      DB 0FFH,0FFH,0D8H,0B6H,0B6H,0B6H,08EH,0FFH ;SO 2

      DB 0C1H,0BEH,0BEH,0BEH,0C1H,0FFH ;SO 0

      DB 0C1H,0BEH,0BEH,0BEH,0C1H,0FFH ;SO 0

      DB 0C9H,0B6H,0B6H,0B6H,0C9H,0FFH ;SO 8

      DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH

      DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH

      DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH

      DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH

      DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH



      END

      Comment

      Về tác giả

      Collapse

      Tmoon Tìm hiểu thêm về Tmoon

      Bài viết mới nhất

      Collapse

      Đang tải...
      X