led matrix 16x64 viết bằng ASM dùng ngắt timer
Quê tôi bị tơi tả vì bảo, bùn quá nên viết code gởi cho anh em kiếm điểm kinh nghiệm.
Thân gởi em Phát và các bạn mới tìm hiểu led matrix, code và mạch mô phỏng bằng proteus 7.5 sp3 chương trình led matix 16x64 chạy chuỗi từ trái qua phải. nếu hay và có ích anh em thanks tui cái nhé
code và ảnh kèm theo:
;************************************************* *******************************
;**************//////------------ MATRIX 16x64 ----------\\\\\\******************
;**------------------------------------------------------------------------------
;**////////////////__ Chuong trinh chay chu tren bo led ___\\\\\\\\\\\\\\\\\\\\\\
;**///////////////__ ma tran 8x8 loai 1 mau ________________\\\\\\\\\\\\\\\\\\\\\
;**//////////////___ Su dung vi dieu khien 89C52 cua ATMEL __\\\\\\\\\\\\\\\\\\\\
;**<<<<<<<<<<<<<---------------------------------------------->>>>>>>>>>>>>>>>>>>
;**\\\\\\\\\\\\\\ __ Thuc hien bien doi du lieu noi tiep ____////////////////////
;**\\\\\\\\\\\\\\\ ___ sang song song roi dua ra day led ___/////////////////////
;**\\\\\\\\\\\\\\\\ ---------- By Tien Huy ---------- //////////////////////
;************************************************* *******************************
;*****
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
;@@@ CAC TEN BIT DUNG TRONG CHUONG TRINH @@@
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
en_hc154 bit p3.3
sh_cp BIT P3.0
data_serial BIT P3.1
st_cp BIT P3.2
f_run BIT 7FH
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
;@@@ CAC TEN BYTE DUNG TRONG CHUONG TRINH @@@
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
data_row equ p2
index_byte_row equ 30h
num_row equ 16
num_byte_collum equ 8
index_point equ 31h
index_reg1 equ 32h
index_reg2 equ 33h
num_bit equ 34h
width_byte equ 35h
buffer_dptrh equ 36h
buffer_dptrl equ 37h
buffer_dptrh1 equ 38h
buffer_dptrl1 equ 39h
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
;@@@ start@@@
;@@@ OSC 12Mhz@@@
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
org 0000h
ljmp main
org 000bh
ljmp ngat_timer0
org 0030h
main:
clr f_run
mov num_bit,#0
mov dptr,#string_code+2
mov a,#0
movc a,@a+dptr
mov width_byte,a
mov dptr,#string_code-6
lcall set_index_dptr
mov buffer_dptrh1,dph
mov buffer_dptrl1,dpl
mov dptr,#string_code+3
mov buffer_dptrh,dph
mov buffer_dptrl,dpl
mov index_point,#0
mov index_byte_row,#0
lcall init_interrupt
ljmp begin
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;################################################# ######################################
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
begin:
___here:
mov ie,#82h
jnb f_run,___here
mov ie,#0
clr f_run
inc num_bit
mov a,num_bit
cjne a,#9,___here
;mov ie,#0
mov num_bit,#0
mov a,dpl
cjne a,buffer_dptrl1,___skip3
mov a,dph
cjne a,buffer_dptrh1,___skip3
mov dptr,#string_code+3
mov buffer_dptrh,dph
mov buffer_dptrl,dpl
mov index_byte_row,#0
sjmp ___here
___skip3:
inc dptr
mov buffer_dptrh,dph
mov buffer_dptrl,dpl
;mov ie,#82h
sjmp ___here
sjmp $
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;################################################# ######################################
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
init_interrupt:
mov tmod,#01h
setb tr0
setb tf0
mov ie,#82h
ret
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;################################################# ######################################
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ngat_timer0:
mov th0,#0f3h
mov tl0,#0a8h ;12^6/12/50hz/16=1250(fb1e)
lcall shift_data
lcall set_index_dptr
inc index_byte_row
mov a,index_byte_row
cjne a,#num_row,___exit
mov index_byte_row,#0
mov dph,buffer_dptrh
mov dpl,buffer_dptrl
setb f_run
___exit:
reti
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;################################################# ######################################
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shift_data:
setb en_hc154 ;ta't ma`ng hi`nh de^? cho^'ng lem led
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov index_reg1,#num_byte_collum
___loop1:
mov index_reg2,#8
mov a,index_point
movc a,@a+dptr ;LAY DU LIEU TRONG BO NHO CT
___loop2:
clr c
rlc a
mov data_serial,c
clr sh_cp
setb sh_cp
djnz index_reg2,___loop2 ;dich du 8 bit
inc index_point
djnz index_reg1,___loop1 ;dich du 8 byte
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov a,num_bit ;de kiem tra co zero
jz ___skip1
mov index_reg2,num_bit
mov a,index_point
movc a,@a+dptr ;LAY DU LIEU TRONG BO NHO CT
___loop3:
clr c
rlc a
mov data_serial,c
clr sh_cp
setb sh_cp
djnz index_reg2,___loop3 ;dich du num_bit bit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
___skip1:
clr st_cp
setb st_cp
mov data_row,index_byte_row ;chon hang va tich cuc hc154
clr en_hc154
mov index_point,#0
ret
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;################################################# ######################################
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
set_index_dptr:
mov a,dpl
add a,width_byte
mov dpl,a
jnc ___skip2
inc dph
___skip2:
ret
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;################################################# ######################################
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
string_code:
;unsigned char code Bmp002:
;-------------------------------------------------------------------------------
; If font display distortion, please check Fonts format of setup.
; Source file / text : I Love dientuvietnam.net @@@ chóc ae vui vÎ
; Width x Height (pixels) :632X16
; Font Format/Size : Monochrome LCD Fonts ,Horizontal scan ,Big endian order/1264Byte
; Font make date : 10/2/2009 4:14:58 PM
;-------------------------------------------------------------------------------
DB 078H,010H,04FH;Width pixels,Height pixels,Width bytes
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,03EH,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,0F8H,000H,000H,000H,000H,000H,000H, 000H,00FH,080H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,070H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,007H
DB 0C0H,000H,000H,036H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,0FFH,080H,0FFH, 080H,000H,000H,000H,000H,000H
DB 001H,0FCH,0F8H,000H,000H,000H,000H,000H,000H,000H, 00FH,080H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,003H, 0F8H,00FH,0E0H,03FH,080H,000H
DB 000H,00FH,0C0H,000H,060H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,007H,0C0H
DB 000H,000H,026H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,07FH,000H,07EH,000H, 000H,000H,000H,000H,000H,000H
DB 07CH,0F8H,000H,000H,000H,004H,000H,000H,000H,00FH, 080H,000H,010H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,040H,007H,0FCH, 01FH,0F0H,07FH,0C0H,000H,000H
DB 007H,0C0H,000H,0C0H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,007H,0C0H,000H
DB 000H,008H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,07FH,000H,07EH,000H,000H, 000H,000H,000H,000H,000H,07CH
DB 070H,000H,000H,000H,00CH,000H,000H,000H,007H,000H, 000H,030H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,0C0H,01EH,00EH,078H, 039H,0E0H,0E0H,000H,000H,007H
DB 0C0H,001H,080H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,003H,080H,000H,000H
DB 010H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,07FH,000H,07EH,000H,000H,000H, 000H,000H,000H,000H,07CH,000H
DB 000H,000H,000H,03CH,000H,000H,000H,000H,000H,000H, 0F0H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,003H,0C0H,019H,0FBH,067H,0EDH, 09FH,0B0H,000H,000H,007H,0C0H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,07FH,000H,07EH,000H,07EH,01FH,0C7H, 01FH,000H,00FH,07DH,0F8H,07CH
DB 03FH,078H,0FFH,0FFH,0F3H,0F8H,0FFH,087H,0C3H,0FFH, 0F7H,081H,0FCH,07EH,0F3H,0C0H
DB 03FH,078H,01FH,00FH,0F0H,03BH,0FBH,0EFH,0EFH,0BFH, 0B0H,000H,01FH,087H,0DEH,03FH
DB 0FCH,01FH,080H,007H,0F0H,03EH,000H,07FH,01FH,0FFH, 0CFH,0C0H,07FH,01CH,07CH,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,07FH,000H,07EH,001H,0E7H,08FH,082H,07BH, 0C0H,01EH,0FCH,0F9H,0EFH,01FH
DB 0FCH,07CH,07DH,0F1H,0F0H,04FH,09EH,0F1H,0F1H,0FFH, 0C7H,09EH,03FH,0FFH,0E0H,01FH
DB 0FCH,07BH,0C7H,0C0H,037H,03BH,0DCH,0EFH,073H,0B0H, 000H,039H,0C7H,0FFH,01FH,07CH
DB 039H,0C0H,01EH,078H,0F7H,080H,03EH,009H,0F7H,0C7H, 0C0H,03EH,009H,0EFH,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,07FH,000H,07EH,001H,0E7H,087H,0C4H,0FBH,0C0H, 01EH,07CH,0FBH,0EFH,01FH,07CH
DB 07CH,07DH,0F0H,0F8H,08FH,0BEH,0F1H,0F1H,0F7H,0C7H, 0DFH,03EH,0FBH,0E0H,01FH,07CH
DB 0FBH,0C7H,0C0H,036H,01BH,0D8H,06FH,061H,0B0H,000H, 073H,0E7H,0DFH,01FH,07CH,073H
DB 0E0H,01FH,07DH,0F7H,080H,01FH,011H,0F7H,0C7H,0C0H, 01FH,013H,0EFH,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 07FH,000H,07EH,003H,0E7H,0C7H,0C4H,0FBH,0E0H,03EH, 07CH,0FBH,0EFH,09FH,07CH,07CH
DB 07DH,0F0H,0F8H,08FH,0BEH,0F9H,0F1H,0F7H,0C0H,01FH, 03EH,0FBH,0E0H,01FH,07CH,0FBH
DB 0E7H,0C0H,036H,032H,0D8H,0CBH,063H,020H,000H,0F3H, 0E7H,0DFH,01FH,07CH,0F3H,0E0H
DB 000H,07DH,0F7H,0C0H,01FH,011H,0F7H,0C7H,0C0H,01FH, 013H,0EFH,080H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,07FH
DB 000H,07EH,00BH,0E7H,0C3H,0E8H,0FFH,0E0H,03EH,07CH, 0FBH,0FFH,09FH,07CH,07CH,07DH
DB 0F0H,07DH,00FH,0BFH,0F9H,0F1H,0F7H,0C3H,0FFH,03EH, 0FBH,0E7H,09FH,07CH,0FFH,0E7H
DB 0C0H,037H,0F6H,0DFH,0DBH,07FH,060H,000H,0F1H,0C7H, 0DFH,01FH,07CH,0F1H,0C0H,00FH
DB 0FDH,0FFH,0C0H,00FH,0A1H,0F7H,0C7H,0C0H,00FH,0A3H, 0FFH,080H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,07FH,000H
DB 07EH,00BH,0E7H,0C3H,0E8H,0F8H,000H,03EH,07CH,0FBH, 0E0H,01FH,07CH,07CH,07DH,0F0H
DB 07DH,00FH,0BEH,001H,0F1H,0F7H,0C7H,09FH,03EH,0FBH, 0EFH,0DFH,07CH,0F8H,007H,0C0H
DB 01BH,0FCH,06FH,0F1H,0BFH,0C0H,000H,0F0H,007H,0DFH, 01FH,07CH,0F0H,000H,01EH,07DH
DB 0F0H,000H,00FH,0A1H,0F7H,0C7H,0C0H,00FH,0A3H,0E0H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,07FH,000H,07EH
DB 019H,0E7H,081H,0F0H,0F8H,000H,01EH,07CH,0FBH,0E0H, 01FH,07CH,07DH,07DH,0F0H,03EH
DB 00FH,0BEH,001H,0F5H,0F7H,0CFH,09FH,03EH,0FBH,0EFH, 0DFH,07CH,0F8H,007H,0D0H,01CH
DB 006H,070H,019H,0C0H,060H,000H,078H,027H,0DFH,01FH, 07CH,078H,020H,03EH,07DH,0F0H
DB 000H,007H,0C1H,0F7H,0C7H,0C0H,007H,0C3H,0E0H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,07FH,000H,07EH,039H
DB 0E7H,081H,0F0H,078H,060H,01FH,0FCH,0F9H,0E1H,09FH, 07CH,07EH,07FH,0F0H,03EH,00FH
DB 09EH,019H,0F9H,0F7H,0C7H,09FH,0BEH,0FBH,0EFH,0DFH, 07CH,078H,067H,0E0H,007H,01CH
DB 01CH,070H,071H,0C0H,000H,038H,047H,0DFH,01FH,0FCH, 038H,040H,01EH,07EH,0F0H,0C0H
DB 007H,0C1H,0FFH,0C7H,0C0H,007H,0C1H,0E1H,080H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,0FFH,080H,0FFH,0F8H,07EH
DB 000H,0E0H,01FH,080H,00FH,07FH,0FCH,07EH,03FH,07EH, 03EH,03DH,0F8H,01CH,01FH,0C7H
DB 0E0H,0FBH,0F7H,0E7H,0EFH,07EH,0FBH,0F7H,0BFH,07EH, 01FH,083H,0E0H,003H,0F0H,00FH
DB 0C0H,03FH,000H,000H,00FH,08FH,0DFH,08FH,07EH,00FH, 080H,01FH,0BCH,03FH,000H,003H
DB 080H,0F7H,0EFH,0E0H,003H,080H,07EH,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
end
Nguyên văn bởi hoangphat
Xem bài viết
Thân gởi em Phát và các bạn mới tìm hiểu led matrix, code và mạch mô phỏng bằng proteus 7.5 sp3 chương trình led matix 16x64 chạy chuỗi từ trái qua phải. nếu hay và có ích anh em thanks tui cái nhé
code và ảnh kèm theo:
;************************************************* *******************************
;**************//////------------ MATRIX 16x64 ----------\\\\\\******************
;**------------------------------------------------------------------------------
;**////////////////__ Chuong trinh chay chu tren bo led ___\\\\\\\\\\\\\\\\\\\\\\
;**///////////////__ ma tran 8x8 loai 1 mau ________________\\\\\\\\\\\\\\\\\\\\\
;**//////////////___ Su dung vi dieu khien 89C52 cua ATMEL __\\\\\\\\\\\\\\\\\\\\
;**<<<<<<<<<<<<<---------------------------------------------->>>>>>>>>>>>>>>>>>>
;**\\\\\\\\\\\\\\ __ Thuc hien bien doi du lieu noi tiep ____////////////////////
;**\\\\\\\\\\\\\\\ ___ sang song song roi dua ra day led ___/////////////////////
;**\\\\\\\\\\\\\\\\ ---------- By Tien Huy ---------- //////////////////////
;************************************************* *******************************
;*****
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
;@@@ CAC TEN BIT DUNG TRONG CHUONG TRINH @@@
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
en_hc154 bit p3.3
sh_cp BIT P3.0
data_serial BIT P3.1
st_cp BIT P3.2
f_run BIT 7FH
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
;@@@ CAC TEN BYTE DUNG TRONG CHUONG TRINH @@@
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
data_row equ p2
index_byte_row equ 30h
num_row equ 16
num_byte_collum equ 8
index_point equ 31h
index_reg1 equ 32h
index_reg2 equ 33h
num_bit equ 34h
width_byte equ 35h
buffer_dptrh equ 36h
buffer_dptrl equ 37h
buffer_dptrh1 equ 38h
buffer_dptrl1 equ 39h
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
;@@@ start@@@
;@@@ OSC 12Mhz@@@
;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
org 0000h
ljmp main
org 000bh
ljmp ngat_timer0
org 0030h
main:
clr f_run
mov num_bit,#0
mov dptr,#string_code+2
mov a,#0
movc a,@a+dptr
mov width_byte,a
mov dptr,#string_code-6
lcall set_index_dptr
mov buffer_dptrh1,dph
mov buffer_dptrl1,dpl
mov dptr,#string_code+3
mov buffer_dptrh,dph
mov buffer_dptrl,dpl
mov index_point,#0
mov index_byte_row,#0
lcall init_interrupt
ljmp begin
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;################################################# ######################################
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
begin:
___here:
mov ie,#82h
jnb f_run,___here
mov ie,#0
clr f_run
inc num_bit
mov a,num_bit
cjne a,#9,___here
;mov ie,#0
mov num_bit,#0
mov a,dpl
cjne a,buffer_dptrl1,___skip3
mov a,dph
cjne a,buffer_dptrh1,___skip3
mov dptr,#string_code+3
mov buffer_dptrh,dph
mov buffer_dptrl,dpl
mov index_byte_row,#0
sjmp ___here
___skip3:
inc dptr
mov buffer_dptrh,dph
mov buffer_dptrl,dpl
;mov ie,#82h
sjmp ___here
sjmp $
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;################################################# ######################################
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
init_interrupt:
mov tmod,#01h
setb tr0
setb tf0
mov ie,#82h
ret
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;################################################# ######################################
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ngat_timer0:
mov th0,#0f3h
mov tl0,#0a8h ;12^6/12/50hz/16=1250(fb1e)
lcall shift_data
lcall set_index_dptr
inc index_byte_row
mov a,index_byte_row
cjne a,#num_row,___exit
mov index_byte_row,#0
mov dph,buffer_dptrh
mov dpl,buffer_dptrl
setb f_run
___exit:
reti
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;################################################# ######################################
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shift_data:
setb en_hc154 ;ta't ma`ng hi`nh de^? cho^'ng lem led
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov index_reg1,#num_byte_collum
___loop1:
mov index_reg2,#8
mov a,index_point
movc a,@a+dptr ;LAY DU LIEU TRONG BO NHO CT
___loop2:
clr c
rlc a
mov data_serial,c
clr sh_cp
setb sh_cp
djnz index_reg2,___loop2 ;dich du 8 bit
inc index_point
djnz index_reg1,___loop1 ;dich du 8 byte
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov a,num_bit ;de kiem tra co zero
jz ___skip1
mov index_reg2,num_bit
mov a,index_point
movc a,@a+dptr ;LAY DU LIEU TRONG BO NHO CT
___loop3:
clr c
rlc a
mov data_serial,c
clr sh_cp
setb sh_cp
djnz index_reg2,___loop3 ;dich du num_bit bit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
___skip1:
clr st_cp
setb st_cp
mov data_row,index_byte_row ;chon hang va tich cuc hc154
clr en_hc154
mov index_point,#0
ret
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;################################################# ######################################
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
set_index_dptr:
mov a,dpl
add a,width_byte
mov dpl,a
jnc ___skip2
inc dph
___skip2:
ret
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;################################################# ######################################
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
string_code:
;unsigned char code Bmp002:
;-------------------------------------------------------------------------------
; If font display distortion, please check Fonts format of setup.
; Source file / text : I Love dientuvietnam.net @@@ chóc ae vui vÎ
; Width x Height (pixels) :632X16
; Font Format/Size : Monochrome LCD Fonts ,Horizontal scan ,Big endian order/1264Byte
; Font make date : 10/2/2009 4:14:58 PM
;-------------------------------------------------------------------------------
DB 078H,010H,04FH;Width pixels,Height pixels,Width bytes
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,03EH,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,0F8H,000H,000H,000H,000H,000H,000H, 000H,00FH,080H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,070H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,007H
DB 0C0H,000H,000H,036H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,0FFH,080H,0FFH, 080H,000H,000H,000H,000H,000H
DB 001H,0FCH,0F8H,000H,000H,000H,000H,000H,000H,000H, 00FH,080H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,003H, 0F8H,00FH,0E0H,03FH,080H,000H
DB 000H,00FH,0C0H,000H,060H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,007H,0C0H
DB 000H,000H,026H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,07FH,000H,07EH,000H, 000H,000H,000H,000H,000H,000H
DB 07CH,0F8H,000H,000H,000H,004H,000H,000H,000H,00FH, 080H,000H,010H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,040H,007H,0FCH, 01FH,0F0H,07FH,0C0H,000H,000H
DB 007H,0C0H,000H,0C0H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,007H,0C0H,000H
DB 000H,008H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,07FH,000H,07EH,000H,000H, 000H,000H,000H,000H,000H,07CH
DB 070H,000H,000H,000H,00CH,000H,000H,000H,007H,000H, 000H,030H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,0C0H,01EH,00EH,078H, 039H,0E0H,0E0H,000H,000H,007H
DB 0C0H,001H,080H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,003H,080H,000H,000H
DB 010H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,07FH,000H,07EH,000H,000H,000H, 000H,000H,000H,000H,07CH,000H
DB 000H,000H,000H,03CH,000H,000H,000H,000H,000H,000H, 0F0H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,003H,0C0H,019H,0FBH,067H,0EDH, 09FH,0B0H,000H,000H,007H,0C0H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,07FH,000H,07EH,000H,07EH,01FH,0C7H, 01FH,000H,00FH,07DH,0F8H,07CH
DB 03FH,078H,0FFH,0FFH,0F3H,0F8H,0FFH,087H,0C3H,0FFH, 0F7H,081H,0FCH,07EH,0F3H,0C0H
DB 03FH,078H,01FH,00FH,0F0H,03BH,0FBH,0EFH,0EFH,0BFH, 0B0H,000H,01FH,087H,0DEH,03FH
DB 0FCH,01FH,080H,007H,0F0H,03EH,000H,07FH,01FH,0FFH, 0CFH,0C0H,07FH,01CH,07CH,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,07FH,000H,07EH,001H,0E7H,08FH,082H,07BH, 0C0H,01EH,0FCH,0F9H,0EFH,01FH
DB 0FCH,07CH,07DH,0F1H,0F0H,04FH,09EH,0F1H,0F1H,0FFH, 0C7H,09EH,03FH,0FFH,0E0H,01FH
DB 0FCH,07BH,0C7H,0C0H,037H,03BH,0DCH,0EFH,073H,0B0H, 000H,039H,0C7H,0FFH,01FH,07CH
DB 039H,0C0H,01EH,078H,0F7H,080H,03EH,009H,0F7H,0C7H, 0C0H,03EH,009H,0EFH,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,07FH,000H,07EH,001H,0E7H,087H,0C4H,0FBH,0C0H, 01EH,07CH,0FBH,0EFH,01FH,07CH
DB 07CH,07DH,0F0H,0F8H,08FH,0BEH,0F1H,0F1H,0F7H,0C7H, 0DFH,03EH,0FBH,0E0H,01FH,07CH
DB 0FBH,0C7H,0C0H,036H,01BH,0D8H,06FH,061H,0B0H,000H, 073H,0E7H,0DFH,01FH,07CH,073H
DB 0E0H,01FH,07DH,0F7H,080H,01FH,011H,0F7H,0C7H,0C0H, 01FH,013H,0EFH,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 07FH,000H,07EH,003H,0E7H,0C7H,0C4H,0FBH,0E0H,03EH, 07CH,0FBH,0EFH,09FH,07CH,07CH
DB 07DH,0F0H,0F8H,08FH,0BEH,0F9H,0F1H,0F7H,0C0H,01FH, 03EH,0FBH,0E0H,01FH,07CH,0FBH
DB 0E7H,0C0H,036H,032H,0D8H,0CBH,063H,020H,000H,0F3H, 0E7H,0DFH,01FH,07CH,0F3H,0E0H
DB 000H,07DH,0F7H,0C0H,01FH,011H,0F7H,0C7H,0C0H,01FH, 013H,0EFH,080H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,07FH
DB 000H,07EH,00BH,0E7H,0C3H,0E8H,0FFH,0E0H,03EH,07CH, 0FBH,0FFH,09FH,07CH,07CH,07DH
DB 0F0H,07DH,00FH,0BFH,0F9H,0F1H,0F7H,0C3H,0FFH,03EH, 0FBH,0E7H,09FH,07CH,0FFH,0E7H
DB 0C0H,037H,0F6H,0DFH,0DBH,07FH,060H,000H,0F1H,0C7H, 0DFH,01FH,07CH,0F1H,0C0H,00FH
DB 0FDH,0FFH,0C0H,00FH,0A1H,0F7H,0C7H,0C0H,00FH,0A3H, 0FFH,080H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,07FH,000H
DB 07EH,00BH,0E7H,0C3H,0E8H,0F8H,000H,03EH,07CH,0FBH, 0E0H,01FH,07CH,07CH,07DH,0F0H
DB 07DH,00FH,0BEH,001H,0F1H,0F7H,0C7H,09FH,03EH,0FBH, 0EFH,0DFH,07CH,0F8H,007H,0C0H
DB 01BH,0FCH,06FH,0F1H,0BFH,0C0H,000H,0F0H,007H,0DFH, 01FH,07CH,0F0H,000H,01EH,07DH
DB 0F0H,000H,00FH,0A1H,0F7H,0C7H,0C0H,00FH,0A3H,0E0H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,07FH,000H,07EH
DB 019H,0E7H,081H,0F0H,0F8H,000H,01EH,07CH,0FBH,0E0H, 01FH,07CH,07DH,07DH,0F0H,03EH
DB 00FH,0BEH,001H,0F5H,0F7H,0CFH,09FH,03EH,0FBH,0EFH, 0DFH,07CH,0F8H,007H,0D0H,01CH
DB 006H,070H,019H,0C0H,060H,000H,078H,027H,0DFH,01FH, 07CH,078H,020H,03EH,07DH,0F0H
DB 000H,007H,0C1H,0F7H,0C7H,0C0H,007H,0C3H,0E0H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,07FH,000H,07EH,039H
DB 0E7H,081H,0F0H,078H,060H,01FH,0FCH,0F9H,0E1H,09FH, 07CH,07EH,07FH,0F0H,03EH,00FH
DB 09EH,019H,0F9H,0F7H,0C7H,09FH,0BEH,0FBH,0EFH,0DFH, 07CH,078H,067H,0E0H,007H,01CH
DB 01CH,070H,071H,0C0H,000H,038H,047H,0DFH,01FH,0FCH, 038H,040H,01EH,07EH,0F0H,0C0H
DB 007H,0C1H,0FFH,0C7H,0C0H,007H,0C1H,0E1H,080H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,0FFH,080H,0FFH,0F8H,07EH
DB 000H,0E0H,01FH,080H,00FH,07FH,0FCH,07EH,03FH,07EH, 03EH,03DH,0F8H,01CH,01FH,0C7H
DB 0E0H,0FBH,0F7H,0E7H,0EFH,07EH,0FBH,0F7H,0BFH,07EH, 01FH,083H,0E0H,003H,0F0H,00FH
DB 0C0H,03FH,000H,000H,00FH,08FH,0DFH,08FH,07EH,00FH, 080H,01FH,0BCH,03FH,000H,003H
DB 080H,0F7H,0EFH,0E0H,003H,080H,07EH,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
DB 000H,000H,000H,000H,000H,000H,000H,000H,000H,000H, 000H,000H,000H,000H,000H,000H
end
Comment