Thông báo

Collapse
No announcement yet.

Help me...Đồng hồ báo chuông dùng ds12c887

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

  • Help me...Đồng hồ báo chuông dùng ds12c887

    Anh chị ui giúp em với. Em đang làm đồ án mạch đồng hồ báo chuông tiết học nhưng phần code viết hoài mà nạp vẫn hok chạy được, em post lên đây nhờ mấy anh chị xem giúp em với, thứ 7 này em phải báo cáo ui, thank mấy anh chị nhiều nhiều.....

    bmode equ r2
    mode bit p3.5
    up bit p3.4
    dwn bit p3.3
    ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    org 0h
    td:
    lcall khoitao
    lcall doc_gpg
    lcall hex_bcd
    lcall bcd_7doan
    lcall hienthi
    lcall delay
    jb mode,adj
    sjmp td
    ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    khoitao:
    mov r0,#0ah
    mov a,#20h
    movx @r0,a
    mov r0,#0bh
    mov a,#06h
    ret
    ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    adj: lcall hienthi; chong nhay man hinh
    jb mode,adj
    inc bmode
    cjne bmode,#04h,b11
    mov bmode,#0h
    ljmp td
    b11: mov 61h,#10h
    b13: mov 60h,#0ffh
    lcall doc_gpg
    lcall hex_bcd
    lcall bcd_7doan
    b12: lcall hienthi
    jb mode,adj
    jb up,tang
    jb dwn,giama
    djnz 60h,b12
    cjne bmode,#01,ss11
    mov 36h,#0ffh; tat don vi gio
    mov 37h,#0ffh; tat hang chuc gio
    sjmp tat
    ss11:
    cjne bmode,#2,ss12
    mov 34h,#0ffh; tat don vi phut
    mov 33h,#0ffh; tat hang chuc phut
    sjmp tat
    ss12:
    mov 30h,#0ffh; tat don vi giay
    mov 31h,#0ffh; tat hang chuc giay
    tat: mov 60h,#0ffh
    tat1: lcall hienthi
    jb mode,adj
    jb up,tang
    jb dwn,giam
    djnz 60h,tat1
    djnz 61h,b13
    mov bmode,#0
    ljmp td
    giama: sjmp giam
    ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    tang: mov 62h,#200; chong doi
    tang1: lcall hienthi
    djnz 62h,tang1
    b26:
    cjne bmode,#1,ss21
    mov r0,#04h
    movx a,@r0
    inc a
    cjne a,#24,b21
    mov a,#0h
    b21: movx @r0,a
    sjmp b22
    ss21: cjne bmode,#2,ss22
    mov r0,#02h
    movx a,@r0
    inc a
    cjne a,#60,b23
    mov a,#0h
    b23: movx @r0,a
    sjmp b22
    ss22: mov r0,#00h
    movx a,@r0
    inc a
    cjne a,#60,b24
    mov a,#0h
    b24: movx @r0,a
    b22: mov 62h,#50
    lcall doc_gpg
    lcall hex_bcd
    lcall bcd_7doan
    b25: lcall hienthi
    djnz 62h,b25
    jb up,b26
    ljmp b11
    ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    giam: mov 62h,#200; chong doi
    giam1: lcall hienthi
    djnz 62h,giam1
    b36:
    cjne bmode,#1,ss31
    mov r0,#04h
    movx a,@r0
    dec a
    cjne a,#0ffh,b31
    mov a,#23h
    b31:
    movx @r0,a
    sjmp b32
    ss31:
    cjne bmode,#2,ss32
    mov r0,#02h
    movx a,@r0
    dec a
    cjne a,#0ffh,b33
    mov a,#59
    b33:
    movx @r0,a
    sjmp b32
    ss32:
    mov r0,#00h
    movx a,@r0
    dec a
    cjne a,#0ffh,b34
    mov a,#59
    b34:
    movx @r0,a
    b32:
    mov 62h,#200
    lcall doc_gpg
    lcall hex_bcd
    lcall bcd_7doan
    b35:
    lcall hienthi
    djnz 62h,b35
    jb dwn,b36
    ljmp b11
    ;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    doc_gpg:
    mov r0,#00h
    movx a,@r0
    mov 10h,a
    mov r0,#02h
    movx a,@r0
    mov 11h,a
    mov r0,#04h
    movx a,@r0
    mov 12h,a
    ret
    hex_bcd:
    mov r0,#10h
    mov r1,#20h
    hb: mov a,@r0
    mov b,#10
    div ab
    mov @r1,b
    inc r1
    mov @r1,a
    inc r0
    inc r1
    cjne r0,#13h,hb
    ret
    bcd_7doan:
    mov dptr,#500h
    mov r0,#20h
    mov r1,#30h
    bc1: mov r7,#02h
    bc: mov a,@r0
    movc a,@a+dptr
    mov @r1,a
    inc r0
    inc r1
    djnz r7,bc
    mov @r1,#0bfh
    inc r1
    cjne r0,#26h,bc1
    ret
    hienthi: mov r0,#30h
    mov a,#0feh
    ht: mov p2,@r0
    mov p1,a
    lcall delay
    mov p1,#0ffh
    inc r0
    rl a
    cjne a,#0feh,ht
    ret
    delay: mov 7fh,#50
    djnz 7fh,$
    ret
    DB 0C0h,0F9h,0A4h,0B0h,99h,92h,82h,0F8h,80h,90h
    end

  • #2
    bạn thử sửa chỗ khởi tạo realtime xem
    khoitao:
    mov r0,#0ah
    mov a,#20h
    movx @r0,a
    mov r0,#0bh
    mov a,#06h
    call delay1s
    ret
    QTCP

    Comment

    Về tác giả

    Collapse

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

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

    Collapse

    Đang tải...
    X