微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 花样流水灯的设计4(单片机-汇编)

花样流水灯的设计4(单片机-汇编)

时间:11-30 来源:互联网 点击:
;This program will show you cycle glitter between 8 led lamps

; maker:Chen Weiwu

; date:2012-11-08

; version:1.0.0

;-------------------------------------------------------------

;Define

Ledprt equ p0

SegDisplay equ p2

Button equ p1

ButtonState equ 30h

;----------------------

;Set the initiation address which the program runing

;----------------------

org 0

ajmp main

;-----------------------

Cycle:

mov a,#low(Tables)

add a,r1

mov dpl,a

clr a

addc a,#high(Tables)

mov dph,a

;---------------------- Get Tables Address

clr a

movc a,@a+dptr

mov r1,a

mov a,#1

movc a,@a+dptr

mov dpl,a

mov dph,r1

;----------------------

clr a

movc a,@a+dptr ;Get the count of data in table

mov r0,a

inc dptr

;----------------------

mov ButtonState,button ;Save button

Loop:

mov a,button

cjne a,ButtonState,ExitCycle ;Buttion is change

clr a

movc a,@a+dptr

mov Ledprt,a

acall delay

inc dptr

djnz r0,Loop

ExitCycle:

ret

;-----------------------

;-----------------------

;delay sub

delay: mov r5,#50

delay1: mov r6,#100

DELAY2: mov r7,#10

djnz r7,$

djnz r6,delay2

djnz r5,delay1

ret

;-----------------------

ButtonTable:

;--------ONE BUTTON--------

db 11111110B

DB 11111101B

db 11111011B

DB 11110111B

;--------TWO BUTTON--------

DB 11111100B

db 11111010B

DB 11110110B

DB 11111001B

db 11110101B

DB 11110011B

;-------THREE BUTTON-------

DB 11111000B

DB 11110100B

DB 11110010B

DB 11110001B

;-------FOUR BUTTON-------

DB 11110000B

DB 0

;-----------------------

Tables: dw Table1,Table2,Table3,Table4

dw Table5,Table6,Table7,Table8,Table9,Table10

dw Table11,Table12,Table13,Table14

dw Table15

dw 0

;-----------------------

Table1: db Table2-$-1

db 11101111b

db 11011111b

db 10111111b

db 01111111b

db 11111110b

db 11111101b

db 11111011b

db 11110111b

db 11111011b

db 11111101b

db 11111110b

db 01111111b

db 10111111b

db 11011111b

Table2: db Table3-$-1

db 01111110b

db 10111101b

db 11011011b

db 11100111b

db 11011011b

db 10111101b

Table3: db Table4-$-1

db 01010101b

db 00000000b

db 10101010b

db 00000000b

Table4: db Table5-$-1

db 11111110b

db 11111100b

db 11111000b

db 11110000b

db 11100000b

db 11000000b

db 10000000b

db 00000000b

db 00000001b

db 00000011b

db 00001111b

db 00011111b

db 00111111b

db 01111111b

db 11111111b

Table5: db Table6-$-1

db 00000000b

db 11111111b

Table6: db Table7-$-1

db 00001111b

db 00011110b

db 00111100b

db 01111000b

db 11110000b

db 01111111b

db 00111111b

db 00011111b

Table7: db Table8-$-1

db 00110110b

db 01010110b

db 01100110b

db 01101010b

db 01101100b

db 01101010b

db 01100110b

db 01010110b

Table8: db Table9-$-1

db 01110111b

db 10110111b

db 11010111b

db 11100111b

db 11101011b

db 11101101b

db 11101110b

db 11101101b

db 11101011b

db 11100111b

db 11010111b

db 10110111b

Table9: db Table10-$-1

db 11100111b

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top