Thông báo

Collapse
No announcement yet.

giải đáp thắc mắc về code

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

  • giải đáp thắc mắc về code

    e đang làm đồ án thiết kế trạm cân sử dụng loadcell.
    mà chạy code dưới đây thì ko hiển thị đc lên lcd. achị chỉ giúp lỗi sai với
    Ale equ p2.1

    Oec equ p2.0

    Oe equ p2.2

    Ka equ p2.3

    Kb equ p2.4

    Kc equ p2.5

    Rs equ p1.0

    Rw equ p1.1

    E equ p1.2

    Org 0000h

    Jmp main

    Org 23h

    Jmp isr_com

    Main:

    Jb p1.3,$

    Mov ie,#10010000b ;ngat com 232, ngat timer0

    Mov tmod,#00100000b ; timer1 che do 2 tao nhip cho toc do buad

    Mov th1,#0fdh ; 9600 . ta 11.0592mhz

    Mov scon,#50h ;1start ,8,n,cho phep ren

    Mov p0,#0ffh ;xac lap cong doc vao

    Setb tr1

    Lap_ko_xuat_data_len_pc:

    Call doc_loadcell

    Call delay

    Call hien_thi_lcd

    Mov 30h,a

    Cjne a,#'s',Lap_ko_xuat_data_len_pc

    Co_ket_noi_may_tinh:

    Call doc_loadcell

    Call delay

    Mov a,40h

    Mov sbuf,a;xuat len may tinh

    Call hien_thi_lcd

    ljMp co_ket_noi_may_tinh

    Doc_loadcell:

    Clr Ka

    Clr Kb

    clr kc

    clr oe

    Setb ale

    Nop

    Nop

    Nop

    Nop

    Clr ale;cho cho chuyen doi xong

    Call delay

    Clr p1.0

    Setb oe

    Nop

    Nop

    Mov a,p0

    Mov 40h,a

    Clr oec

    Ret

    Tach_chuyen_doi_ma_thap_phan_to_ascii:

    Mov a,40h

    Mov b,#100

    Div ab

    Mov 41h,a;luu hang tram

    Mov a,b

    Mov b,#10

    Div ab

    Mov 42h,a;luu hang chuc

    Mov 43h,b;luu hang don vi

    Mov r0,#40h

    Mov r1,#50h

    Giai_ma_tiep:

    Mov a,@r0

    Clr c

    Add a,#48

    Mov @r1,a

    Inc r0

    Inc r1

    Cjne r1,#53h,giai_ma_tiep

    Ret

    Khoi_tao_lcd:

    Mov a,#38h;chon lcd hien thi 2dong matrix 5*7

    Call guilenh;chuong trinh con nap lenh

    Call delay

    Mov a,#0Ch;hien thi man hinh va nhap nhay con tro

    Call guilenh

    Call delay

    Mov a,#80h;dich sang phai

    Call guilenh

    Call delay

    Ret

    Hien_thi_lcd:

    mov a,#'k';chu k

    Call hienthi

    Call delay

    Mov a,#'h';chu h

    Call hienthi

    Call delay

    Mov a,#'o';chu o

    Call hienthi

    Call delay

    Mov a,#'i';chu i

    Call hienthi

    Call delay

    Mov a,#'L';chu l

    Call hienthi

    Call delay

    Mov a,#'u';chu u

    Call hienthi

    Call delay

    Mov a,#'o';chu o

    Call hienthi

    Call delay

    Mov a,#'n';chu n

    Call hienthi

    Call delay

    Mov a,#'g';chu g

    Call hienthi

    Call delay

    Mov a,50h;con so hang van

    Call hienthi

    Call delay

    Mov a,50h;con so hang nghin

    Call hienthi

    Call delay

    Mov a,50h;con so hang tram

    Call hienthi

    Call delay

    Mov a,#'0';con so hang chuc

    Call hienthi

    Call delay

    Mov a,#0;con so hang donvi

    Call hienthi

    Call delay

    Mov a,#'g';don vi g

    Call hienthi

    Call delay

    Guilenh:

    Mov p1,a;dua ma lenh ra p1

    Clr rs;dat rs=0 de thuc hien gui lenh

    Clr rw;dat rw=0 de thuc hien ghi

    Setb e;dua chan e len cao de chuan bi chot data

    Clr e;cho xong xuon de chot

    Ret

    Hienthi:

    Mov p1,a

    Setb rs;thuc hien ghi du lieu ht

    Clr rw

    Setb e

    Clr e

    Ret

    Delay:

    Mov r7,#50

    Dell:

    Mov r6,#0ffh

    Djnz r6,$

    Djnz r7,dell

    Ret

    Isr_com:

    Jnb ri,trans

    Mov a,sbuf

    Mov 30h,a

    Clr ri

    Reti

    Trans:

    Clr ti

    Reti

    END

Về tác giả

Collapse

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

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

Collapse

Đang tải...
X