Thông báo

Collapse
No announcement yet.

Hỏi về quét led matrix

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

  • Hỏi về quét led matrix

    Các anh cho em hỏi. Em viết 2 chương trinh asm quet led theo hai chiều trai sang phải và ngược lại. Nhưng bây giò làm thế nào để ghép 2 chương trình này với nhau nạp vào 8051 để khi bật lên nó có thể tự động chạy theo 2 chiều tuần tự.

  • #2
    ban có thể tham khảo cái của mình sau đây thử,mình mô phỏng thấy cũng đc


    $MOD51

    ORG 00H
    MAIN:

    SDATA BIT P2.0
    CK BIT P2.2
    CLEAR BIT P2.1
    //************************************************** *************
    PHAI_TRAI:
    MOV DPTR,#DATABASE ;DIA CHI NAP DU LIEU, DAT CON
    ; TRO CUOI VUNG MA
    MP5:
    MOV R0,#10 ;THOI GIAN CUA 1 TRANG THAI MAN
    ;HINH LED
    MP6:
    LCALL SCANDATA ;HIEN THI DU LIEU
    DJNZ R0,MP6
    INC DPTR
    MOV A,DPL
    MOV R1,DPH
    CJNE R1,#HIGH(DATABASE+64),MP5
    CJNE A,#LOW(DATABASE+64),MP5

    ljmp TRAI_PHAI

    TRAI_PHAI:
    MOV DPTR,#DATABASE+64 ;DIA CHI NAP DU LIEU, DAT CON
    ; TRO CUOI VUNG MA
    MP3:
    MOV R0,#10
    ;THOI GIAN CUA 1 TRANG THAI MAN
    ;HINH LED
    MP4:
    LCALL SCANDATA ;HIEN THI DU LIEU
    DJNZ R0,MP4
    LCALL DEC_DPTR
    MOV A,DPL
    MOV R1,DPH
    CJNE R1,#HIGH(DATABASE),MP3
    CJNE A,#LOW(DATABASE),MP3


    DEC_DPTR:
    PUSH ACC
    DEC DPL
    MOV A,DPL
    CJNE A,#00H,SKIP
    DEC DPH
    SKIP:
    POP ACC
    RET

    SCANDATA:
    PUSH ACC
    PUSH 00H
    PUSH 01H

    ;HIEN THI RA COT DAU TIEN

    SETB SDATA
    SETB CK
    NOP
    CLR CK
    CLR SDATA
    SETB CLEAR
    NOP
    CLR CLEAR
    MOV R0,#00H

    SCAN:
    MOV P0,#00H
    MOV A,R0
    MOVC A,@A+DPTR ;NAP DU LIEU TU DATABASE VAO A
    MOV P0, A ;HIEN THI RA DONG TUONG UNG

    LCALL DELAYMS ;CHUONG TRINH TAO TRE 5 MS
    MOV P0,#0FFH ;HIEN THI RA COT DAU TIEN
    SETB CK
    NOP
    CLR CK
    SETB CLEAR
    NOP
    CLR CLEAR
    INC R0
    CJNE R0,#32H ,SCAN


    POP 01H
    POP 00H
    POP ACC
    RET



    DELAYMS:


    PUSH 00H
    PUSH 01H
    MOV R1,#1
    DEL:

    MOV R0,#250
    DJNZ R0,$
    DJNZ R1,DEL
    POP 01H
    POP 00H
    RET
    ret

    DATABASE:
    DB 0FFH,0FFH,0FFH,0FFH,0FFH ,0FFH,0FFH ,0FFH
    DB 0FFH,0FFH,0FFH,0FFH,0FFH ,0FFH,0FFH ,0FFH
    DB 0FFH,0FFH,0FFH,0FFH,0FFH ,0FFH,0FFH ,0FFH
    DB 0FFH,0FFH,0FFH,0FFH,0FFH ,0FFH,0FFH ,0FFH
    DB 1H,0FBH,0F7H,0EFH,1H,0FFH
    DB 1H,6DH,6DH,7DH,7DH,0FFH
    DB 1H,0EDH,0EDH,0EDH,0F3H,0FFH
    DB 83H,7DH,7DH,7DH,83H,0FFH
    DB 0FFH,0FFH,0FFH,0FFH,0FFH ,0FFH,0FFH ,0FFH
    DB 0FFH,0FFH,0FFH,0FFH,0FFH ,0FFH,0FFH ,0FFH
    DB 0FFH,0FFH,0FFH,0FFH,0FFH ,0FFH,0FFH ,0FFH
    DB 0FFH,0FFH,0FFH,0FFH,0FFH ,0FFH,0FFH ,0FFH
    DB 0FFH,0FFH,0FFH,0FFH,0FFH ,0FFH,0FFH ,0FFH

    Comment


    • #3
      ah,bạn có thể chỉ dùm mình chay, chữ trên xuống ko,mình laoy hoay mãi mà ko dc

      Comment


      • #4
        Cụ thể là mình có 2 chuơng trình riêng biệt như sau. Nhưng chưa biet cách ghép nó lạimạch em quét 4 led matrix theo cột)
        Chuơng trinh trai sang phai
        org 0000h ;
        batdau:
        mov DPTR,#maled
        lap:mov r0,#30
        main1 :
        mov r2,#24
        mov r1,#16
        mov r7,#8
        mov b ,#0
        mov r3,#00feh

        main2:
        mov a,r3
        rr a
        mov r3,a
        mov p1,a
        setb p3.1
        setb p3.2
        setb p3.3
        clr p3.0
        mov a,b
        movc a,@a+DPTR
        mov p2,a
        inc b
        acall delay
        cjne r3,#00feh,main2
        main3:
        mov a,r3
        rr a
        mov r3,a
        mov p1,a
        clr p3.1
        setb p3.0
        setb p3.2
        setb p3.3
        mov a,r7
        movc a,@a+DPTR
        mov p2,a
        inc r7
        acall delay
        cjne r3,#00feh,main3
        main4:
        mov a,r3
        rr a
        mov r3,a
        mov p1,a
        clr p3.2
        setb p3.0
        setb p3.1
        setb p3.3
        mov a,r1
        movc a,@a+DPTR
        mov p2,a
        inc r1
        acall delay
        cjne r3,#00feh,main4
        main5:
        mov a,r3
        rr a
        mov r3,a
        mov p1,a
        clr p3.3
        setb p3.2
        setb p3.0
        setb p3.1
        mov a,r2
        movc a,@a+DPTR
        mov p2,a
        inc r2
        acall delay
        cjne r3,#00feh,main5

        djnz r0,main1
        inc DPTR
        mov a,DPL
        cjne a,#144,lap
        sjmp batdau
        delay :
        push 04
        push 05
        push 06
        mov r4,#4
        n1:mov r5,#4
        n2:mov r6,#4
        n3:djnz r6,n3
        djnz r5,n2
        djnz r4,n1
        pop 06
        pop 05
        pop 04
        ret

        delay2:
        mov r4,#4
        m1:mov r5,#4
        m2:mov r6,#4
        m3:djnz r6,m3
        djnz r5,m2
        djnz r4,m1
        ret
        org 800h

        maled: db 0h, 0h, 0h, 0h, 0h, 0h ,0h, 0h
        db 0h, 0h, 0h, 0h, 0h, 0h, 0h, 0h
        db 0h, 0h, 0h, 0h, 0h, 0h, 0h, 0h
        db 0h, 0h, 0h, 0h, 0h, 0h, 0h, 0h
        DB 0H,0H,0H,0FFH,20H,10H,8H,4H,2H,0FFH,0H,3CH,42H,81H ,81H,81H,42H,3CH,80H,80H,80H,80H,80H,0FFH
        DB 0H,0H,0H,0EH,11H,11H,11H,11H,0FFH,0H,0FCH,12H,11H, 11H,12H,0FCH,0H,1H,1H,1H,0FFH,1H,1H,1H
        DB 0H,0H,0H,0H,0H,81H,81H,0FFH,81H,81H,0H,0FCH,12H,11 H,11H,12H,0FCH,0H,66H,99H,89H,89H,89H,0FFH


        end
        chuơng trình phải sang trái
        org 0000h
        batdau:
        mov DPTR,#maled
        lap:mov r0,#30
        main1 :
        mov r2,#24
        mov r1,#16
        mov r7,#8
        mov b ,#0
        mov r3,#7fh

        main2:
        mov a,r3
        rl a
        mov r3,a
        mov p1,a
        setb p3.3
        setb p3.2
        setb p3.3
        clr p3.0
        mov a,r2
        movc a,@a+DPTR
        mov p2,a
        inc r2
        acall delay
        cjne r3,#07fh,main2
        main3:
        mov a,r3
        rl a
        mov r3,a
        mov p1,a
        clr p3.1
        setb p3.0
        setb p3.2
        setb p3.3
        mov a,r1
        movc a,@a+DPTR
        mov p2,a
        inc r1
        acall delay
        cjne r3,#07fh,main3
        main4:
        mov a,r3
        rl a
        mov r3,a
        mov p1,a
        clr p3.2
        setb p3.0
        setb p3.1
        setb p3.3
        mov a,r7
        movc a,@a+DPTR
        mov p2,a
        inc r7
        acall delay
        cjne r3,#07fh,main4
        main5:
        mov a,r3
        rl a
        mov r3,a
        mov p1,a
        clr p3.3
        setb p3.2
        setb p3.0
        setb p3.1
        mov a,b
        movc a,@a+DPTR
        mov p2,a
        inc b
        acall delay
        cjne r3,#07fh,main5

        djnz r0,main1
        inc DPTR
        mov a,DPL
        cjne a,#200,lap
        sjmp batdau
        delay :
        push 04
        push 05
        push 06
        mov r4,#4
        n1:mov r5,#4
        n2:mov r6,#4
        n3:djnz r6,n3
        djnz r5,n2
        djnz r4,n1
        pop 06
        pop 05
        pop 04
        ret

        delay2:
        mov r4,#4
        m1:mov r5,#4
        m2:mov r6,#4
        m3:djnz r6,m3
        djnz r5,m2
        djnz r4,m1
        ret
        org 800h

        maled: db 0h, 0h, 0h, 0h, 0h, 0h ,0h, 0h
        db 0h, 0h, 0h, 0h, 0h, 0h, 0h, 0h
        db 0h, 0h, 0h, 0h, 0h, 0h, 0h, 0h
        db 0h, 0h, 0h, 0h, 0h, 0h, 0h, 0h
        DB 81H,0FFH,0FFH,99H,38H,0E5H,0C3H,81H,80H,1H,3H,0FH, 8DH,0F8H,0F0H,8CH,5H,3H,1H,0H,0H,0H,0H,0H
        DB 3H,3H,81H,0FFH,0FFH,81H,3H,3H,0H,81H,0FFH,0FFH,91H ,10H,91H,0FFH,0FFH,81H,0H,1H,3FH,0FFH,0C1H,80H
        DB 80H,0C1H,7FH,81H,0E0H,0B8H,1EH,13H,9EH,0F8H,0E0H,8 0H,3H,3H,81H,0FFH,0FFH,81H,3H,3H,0H,0H,0H,0H
        DB 1H,7H,1FH,39H,0E0H,60H,38H,0DH,7H,1H,0H,0H,81H,0FF H,0FFH,81H,0H,0H,0H,0H,0H,0H,0H,0H
        DB 81H,0C3H,0E7H,2DH,18H,38H,0E5H,0C3H,81H,0H,1H,7FH, 0FFH,81H,80H,80H,0C1H,7FH,1H,0H,0H,0H,0H,0H
        DB 81H,0FFH,0FFH,81H,80H,80H,80H,0C0H,0H,1H,3H,87H,0F DH,0F8H,88H,5H,3H,1H,0H,0H,0H,0H,0H,0H
        DB 81H,0FFH,0FFH,99H,18H,0B5H,0E3H,81H,0H,0H,87H,85H, 85H,8DH,79H,20H,0H,30H,38H,24H,22H,0FFH,0FFH,20H

        end

        Comment


        • #5
          Chưa ai giúp em cả nhà nhỉ!

          Comment

          Về tác giả

          Collapse

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

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

          Collapse

          Đang tải...
          X