Đánh giá chủ đề:
  • 53 Vote(s) - Trung bình 2.34
  • 1
  • 2
  • 3
  • 4
  • 5
Mạch đếm sản phẩm dùng AT89
Bài viết: #1
[Image: jrnM5DBrqaIrXAMmorMMeT2CzpHXnr2mEnuRSPcy9w=w771-h532-no]
Code ASM
dataport equ p2 // xuat du lieu ra p2
ctrl equ p1 // p1 la port dieu khien de quet led
led1 equ 0 // led 1 la p1.0
led2 equ 1 // led 2 la p1.1
led3 equ 2 // led 3 la p1.2
a_ equ 11111110b
b_ equ 11111101b
c_ equ 11111011b
d equ 11110111b
e equ 11101111b
f equ 11011111b
g equ 10111111b
dp equ 01111111b
dseg at 30h
dv : ds 1
ch : ds 1
tr : ds 1
delay0: ds 1
delay1: ds 1
cseg at 00h
ljmp begin
//-----------------------------
// Khai bao ngat ngoai 1
cseg at 13h
ljmp ext1_isr
begin:
// cau hinh ngat ngoai 1
clr IE1
setb IT1
setb EX1
setb EA
mov ctrl,#0FFh //lenh dieu khien p1
mov dptr,#bitmap
mov dv,#0
mov ch,#0
mov tr,#0
l:
lcall hienthi
ljmp l
// khai bao ngat ngoai 1
ext1_isr:
//moi khi co ngat say ra thi se goi chuong trinh dem tang(count_up)
lcall count_up
reti
// dem tang tu 000-999
count_up:
inc dv
mov r0,dv
cjne r0,#10,count_exit
mov dv,#0
inc ch
mov r0,ch
cjne r0,#10,count_exit
mov ch,#0
inc tr
mov r0,tr
cjne r0,#10,count_exit
mov tr,#0
count_exit:
ret
// quet led 7 doan
hienthi:
mov dptr,#bitmap
mov a,dv
movc a,@a+dptr
mov dataport,a
setb ctrl.led3
lcall delay_2ms
clr ctrl.led3


mov dptr,#bitmap
mov a,ch
movc a,@a+dptr
mov dataport,a
setb ctrl.led2
lcall delay_2ms
clr ctrl.led2


mov dptr,#bitmap
mov a,tr
movc a,@a+dptr
mov dataport,a
setb ctrl.led1
lcall delay_2ms
clr ctrl.led1

ret
// thoi gian delay 2mms
delay_2ms:
mov delay0,#2
loop_0:
mov delay1,#250
loop_1:
nop
nop
djnz delay1,loop_1
djnz delay0,loop_0
ret
// Bang ma led 7 doan
bitmap:
db ~(g&dp)
db b_&c_
db ~(c_&f&dp)
db ~(e&f&dp)
db ~(a_&d&e&dp)
db ~(b_&e&dp)
db ~(b_&dp)
db a_&b_&c_
db ~dp
db ~(e&dp)

end
code: You are not allowed to view links. Register or Login to view.
Mạch mô phỏng (Protues): You are not allowed to view links. Register or Login to view.
Sơ đồ mạch in:
Capture: You are not allowed to view links. Register or Login to view.
Layout: You are not allowed to view links. Register or Login to view.
sdt:01665.217.473
You are not allowed to view links. Register or Login to view.
Trả lời
Bài viết: #2
vì sao lại code asm
Trả lời


Đi tới chuyên mục:


Thành viên đang xem chủ đề: 1 Khách