历史上的今天
返回首页

历史上的今天

今天是:2025年12月21日(星期日)

2022年12月21日 | LED迷你烟花灯汇编源代码

2022-12-21 来源:zhihu

;*****************************************

; 78p153寄存器定义

;有渐变功能,用在迷你烟花灯路机.

;

;*****************************************

R0 == 0X0 ;间接寻址IAR

;****CONT REGISTE*************

; 7 6 5 4 3 2 1 0

; - INT TS TE PAB PSR2 PSR1 PSR2

; PSR TCC RATE WDT RATE

; 000 1:2 1:1

; 001 1:4 1:2

; 010 1:8 1:4

; 011 1:16 1:8

; 100 1:32 1:16

; 101 1:64 1:32

; 110 1:128 1:64

; 111 1:256 1:128

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

; PAB 0:TCC 1:WDT

; TE TCC信号边沿选择位。0:由高到低加1。 1:由低到高加1

; TS TCC信号源 0:内部时钟。 1:外部输入(P62/TCC)

; INT 中断使能标志 0:由DISI或硬件中断屏蔽,1:由ENI/RETL使能中断。

TCC == 0X1

PC == 0X2

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

STATUS == 0X3

C == 0

DC == 1

Z == 2

P == 3 ;执行SLEP时置为0

T == 4 ;时间溢出时置为0

GP0 == 5 ;

GP1 == 6 ;

RST == 7 ;复位类型,由引脚唤醒时置1,其它复位置0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

R4 == 0X4

PORT5 == 0X5

IOC5 == 0X5

PORT6 == 0X6

IOC6 == 0X6

IOCB == 0X0B ;将P50,P51,P52, P60,P61,P62下拉

IOCC == 0X0C ;将P60,P61,P62, P64,P65,P66,P67漏极开路

IOCD == 0X0D ;将P60,P61,P62, P64,P65,P66,P67上拉

;0: 为允许使能。 1:为禁止

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

IOCE == 0X0E ;WDT控制器

WDTE == 7 ;0:禁止,1:允许

EIS == 6 ;0:P60,双向I/O口,1:外部中断管脚。此时IOC6的BIT0置为1(输入)

;为“0”时,/通道被屏蔽。INT为“1”时,可通由P6口读取其状态

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

ISR == 0XF ;中断状态寄存器

TCIF == 0 ;TCC溢出时置1,软件清0

ICIF == 1 ;P6口输入变化置1,软件清0

EXIF == 2 ;外部中断,由P60/INT下降沿置1,软件清0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

IOCF == 0XF ;中断屏蔽寄存器

TCIE == 1 ;0:为中断禁止。1为中断允许

ICIE == 2 ;

EXIE == 3 ;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

count1 == 0x12

count2 == 0x13

count3 == 0x14

temp == 0x15

chtbl == 0x16

time == 0x17

cord1 == 0x18

cord2 == 0x19

cord3 == 0x1a

chtb2 == 0x1b

cord4 == 0x1c

wmode == 0x1f

next == 0x11

org 0x0

jmp start

tbl0:

add pc,a ;这是没有渐变的

retl 0b00000000

retl 0b01100000

retl 0b01110000

retl 0b10110001

retl 0b10110011

retl 0b10110111

retl 0b11111111

retl 0b01001111

retl 0b00111110

retl 0b00101100

retl 0b00011000 ;6

retl 0b10110000

retl 0b00110001

retl 0b00110010

retl 0b00100100

retl 0b00101000 ;5

retl 0b10110000

retl 0b00110001

retl 0b00110010

retl 0b00100100

retl 0b00101000 ;5

retl 0b10110000

retl 0b00110001

retl 0b00110010

retl 0b00100100

retl 0b00101000 ;5

retl 0b10110000

retl 0b00110001

retl 0b00100010

retl 0b00010100

retl 0b00011000 ;5

retl 0b10110000

retl 0b00110001

retl 0b00110010

retl 0b00100100

retl 0b00101000 ;5

retl 0b01000000

retl 0b01100000

retl 0b11010000

retl 0b01000001

retl 0b00110010

retl 0b00100100

retl 0b00011000

retl 0b10110000

retl 0b00110001

retl 0b00110010

retl 0b00100100

retl 0b00101000

retl 0b10110000

retl 0b00110001

retl 0b00110010

retl 0b00100100

retl 0b00101000 ;17,2

retl 0b01100000

retl 0b11010000

retl 0b11000001

retl 0b10110011

retl 0b10110111

retl 0b00101111

retl 0b00101110

retl 0b00011100

retl 0b00011000 ;9,1

retl 0b01000000

retl 0b01110000

retl 0b11010000

retl 0b01000001

retl 0b00110010

retl 0b00100100

retl 0b00011000

retl 0b10110000

retl 0b00110001

retl 0b00110010

retl 0b00100100

retl 0b00101000 ;12,2

retl 0b01100000

retl 0b11010000

retl 0b11000001

retl 0b10110011

retl 0b10110111

retl 0b00101111

retl 0b00101110

retl 0b00011100

retl 0b00011000 ;9,1

tbl11:

add pc,a

retl 0b00000000 ;流星划过,全过程梦幻

retl 0b00000000

retl 0b00000000

retl 0b00110000

retl 0b00010000

retl 0b00011100

retl 0b10001111

retl 0b10001111

retl 0b00100000

retl 0b00100000

retl 0b10010000

retl 0b10001111

retl 0b10001111

retl 0b00100000

retl 0b00100000

retl 0b00011100

retl 0b10001111

retl 0b10001111

retl 0b00010000

retl 0b00110000

retl 0b00100000

retl 0b10010000

retl 0b10010111

retl 0b10001111

retl 0b10001110

retl 0b00110000

retl 0b00110000

retl 0b00100000

retl 0b10010000

retl 0b10010111

retl 0b10001111

retl 0b10001110 ;14

retl 0b01000000

retl 0b00010000

retl 0b00110000

retl 0b10110000

retl 0b10100000

retl 0b10100001

retl 0b00010011

retl 0b00010110

retl 0b00001100

retl 0b10000000

retl 0b10000000

retl 0b10000000

retl 0b10000001

retl 0b00000011

retl 0b00000110

retl 0b00001100

retl 0b10000000

retl 0b10000000

retl 0b10000000

retl 0b10000001

retl 0b00000011

retl 0b00000110

retl 0b00001100

retl 0b10000000

retl 0b10000000

retl 0b10000000

retl 0b10000001

retl 0b00000011

retl 0b00000110

retl 0b00001100

retl 0b00000000 ;4连发31

retl 0b00110000

retl 0b00010000 ;停顿一段时间

retl 0b00110000

retl 0b10110000

retl 0b10100000

retl 0b10100001

retl 0b00010011

retl 0b00010110

retl 0b00001100

retl 0b10000000

retl 0b10000000

retl 0b10000001

retl 0b00000011

retl 0b00000110

retl 0b00001100

retl 0b00000000 ;双响16

retl 0b00110000 ;停顿一段时间

retl 0b00010000

retl 0b00110000

retl 0b10110000

retl 0b10100001

retl 0b10100011

retl 0b00010111

retl 0b00011110

retl 0b00001100

retl 0b10000000

retl 0b10000001

retl 0b10000011

retl 0b00000111

retl 0b00001110

retl 0b00001100

retl 0b00000000 ;双响16


retl 0b00110000

retl 0b00010000

retl 0b00000000

retl 0b10010001

retl 0b10100011

retl 0b10100111

retl 0b10101111

retl 0b10101111

retl 0b10011111

retl 0b10001111

retl 0b00001111

retl 0b00001110

retl 0b00001100

retl 0b00000000

retl 0b00000000

retl 0b00000000

retl 0b00000000 ;扫过17

retl 0b00110000

retl 0b00010000

retl 0b10000000

retl 0b10010001

retl 0b10010011

retl 0b10100111

retl 0b10101111

retl 0b10101111

retl 0b10101111

retl 0b10001111

retl 0b00001111

retl 0b00001110

retl 0b00001100

retl 0b00000000

retl 0b00000000

retl 0b00000000

retl 0b00000000 ;扫过17

tbl2:

add pc,a

retl 0b00000000

retl 0b10100011 ;6

retl 0b00011110

retl 0b10011111

retl 0b00100111

retl 0b00100011

retl 0b10101100


org 0x100

;org 0x1c0

start:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;init初始化

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

mov a,@0b01111111

iow ioc6 ;p67口作为输出

;clr port6

mov a,@0b00000000

iow ioc5

iow iocb ;port5下拉

clr port5

mov a,@0b11111110

iow iocd ;禁止上拉port6上拉

mov a,@0x01

iow iocc

;clr port6

clr port5

mov a,@4 ;有4种状态

mov wmode,a ;定义工作模式3,为全部模式

mov a,@01

iow iocf ;开TCC中断

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;boom3在时间方面差不多了,功能是单调,不要进行太多

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

boom3:

mov a,@4 ;只进行3次

mov count2,a

boom32:

mov a,@83 ;共有这么多个点

mov chtbl,a

boom31:

mov a,chtbl

call tbl0 ;

mov cord1,a

call display1 ;display1是一个单一的输出

djz chtbl

jmp boom31

djz count2

jmp boom32

mov a,wmode

xor a,@04

jbs status,z

jmp boom3

;;;;;;;;;;;;;;;;;;

;boom4

;;;;;;;;;;;;;;;;;;

boom4:

mov a,@4

mov count2,a

boom42:

mov a,@6

mov chtbl,a

boom41:

mov a,chtbl

call tbl2

mov cord1,a ;为什么只取一个码

call display2 ;两状态显示

nop

djz chtbl

jmp boom41

djz count2

jmp boom42

mov a,wmode

xor a,@04

jbs status,z

jmp boom4

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

luxing:

mov a,@2

mov count2,a

luxing02:

mov a,@125

mov chtbl,a

luxing01:

mov a,chtbl

mov chtb2,a

mov a,chtb2

call tbl11

mov cord1,a ;取出cord1

inc chtb2

mov a,chtb2

call tbl11

mov cord2,a ;取出cord2

inc chtb2

mov a,chtb2

call tbl11

mov cord3,a ;取出cord3


call display3 ;三态显示

djz chtbl

jmp luxing01

djz count2

jmp luxing02

mov a,wmode

xor a,@0b00000100

jbs status,z

jmp luxing

jmp boom3

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

display2: ;特点是转换时间不到256拍

mov a,cord1

mov temp,a

rrc temp

rrc temp

rrc temp

rrc temp

mov a,@0b00000111 ;

and temp,a

mov a,temp ;在代码中取出分频比来确定速度

contw


mov a,@0xff

mov time,a

disp23:

mov a,@3

mov count3,a

disp21:

mov a,cord1

mov port6,a

mov port5,a

com time

call delay

jbc next,0

jmp chmode

clr port6

clr port5

com time

call delay

djz count3

jmp disp21

;mov a,@50

;sub time,a

djz time

jmp disp23

ret

;disp22:

; mov a,@50

;add time,a

;jmp disp23

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;

;;

display3: ;有渐变

mov a,cord1

mov temp,a

rrc temp

rrc temp

rrc temp

rrc temp

mov a,@0b00000111 ;

and temp,a

mov a,temp ;在代码中取出分频比来确定速度

contw

mov a,@0xa0 ;可用COUNT1

mov time,a


disp32:

mov a,@1

mov count3,a ;count3才决定快慢

disp31:

mov a,cord3

mov port6,a

mov port5,a

com time

call delay

jbc next,0

jmp chmode

mov a,cord2

mov port6,a

mov port5,a

com time ;由1向2过渡

call delay

jbc next,0

jmp chmode

com time

call delay

jbc next,0

jmp chmode

mov a,cord1

mov port6,a

mov port5,a

com time ;由2向3过渡

call delay

jbc next,0

jmp chmode

djz count3 ;count3为1,让时间最短。

jmp disp31

djz time

jmp disp32

ret

ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;

;

;;;;;;;;;;;;;;;;;;;;;;;;;;;

display4: ;有渐变

mov a,cord1

mov temp,a

rrc temp

rrc temp

rrc temp

rrc temp

mov a,@0b00000111 ;

and temp,a

mov a,temp ;在代码中取出分频比来确定速度

contw

mov a,@0xff ;可用COUNT1

mov time,a

disp42:

mov a,@1

mov count3,a

disp41:

mov a,cord4

mov port6,a

mov port5,a

com time

call delay

jbc next,0

jmp chmode

mov a,cord3

;mov port6,a

mov port5,a

com time

call delay

jbc next,0

jmp chmode

com time

call delay

jbc next,0

jmp chmode

mov a,cord2

;mov port6,a

mov port5,a

com time ;由1向2过渡

call delay

jbc next,0

jmp chmode

com time

call delay

jbc next,0

jmp chmode

mov a,cord1

mov port6,a

mov port5,a

com time ;由2向3过渡

call delay

jbc next,0

jmp chmode

djz count3

jmp disp41

djz time

jmp disp42

ret

ret


display1: ;无渐变

mov a,cord1 ;输出

mov port6,a

mov port5,a

mov a,cord1

mov temp,a

rrc temp

rrc temp

rrc temp

rrc temp

mov a,@0b00000111 ;设定时间分频比

and a,temp

contw


mov a,@25 ;这个常数决定时间

mov count3,a

disp11:

clr time

;count3是一个内循环

call delay

jbc next,0

jmp chmode

djz count3

jmp disp11

clr port6

clr port5

ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

/*display2:

mov a,cord1

mov temp,a

rrc temp

rrc temp

rrc temp

rrc temp

mov a,@0b00000111

and a,temp

contw

mov a,@0xff

mov time,a

disp22:

mov a,@3

mov count3,a

disp21:

mov a,cord1

mov port6,a

mov port5,a

com time

call delay

jbc next,0

jmp chmode

mov a,cord2

mov port6,a

mov port5,a

com time

call delay

jbc next,0

jmp chmode

djz count3

jmp disp21

djz time

jmp disp22

ret

ret

*/

;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; 延时与扫描按键

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

delay:

clr next ;进入之前也清0

clr isr

mov a,time

mov tcc,a

delay10:

jbs isr,tcif

jmp delay10 ;延时时间到否

jbc port6,0 ;时间到,顺便查下按键p61口

ret ;无按下动作,则直接返回

keyscan:

mov a,@0xff ;一个短延时

mov temp,a

keyscan01:

djz temp

jmp keyscan01

jbc port6,0 ;再次查P61口

ret ;是干扰,返回

clr port5 ;不是,

bs next,0

nop

jbs port6,0

jmp $-2 ;等待放开按键

djz wmode ;设为下一模式

jmp keyscan02

mov a,@03

mov wmode,a

jmp keyscan04

keyscan02:

mov a,@06

contw

mov a,@2

mov count3,a

keyscan03:

clr port5

call delay2

call delay2

mov a,@0x0f

mov port5,a

call delay2

call delay2

djz count3

jmp keyscan03

keyscan04:

clr port5

call delay2

call delay2

call delay2

ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

delay2:

clr isr

mov a,@06

mov tcc,a

delay20:

jbs isr,tcif

jmp delay20

ret

ret


chmode:

mov a,wmode

mov count3,a

djz count3

jmp chmode1

jmp luxing;第一种模式

chmode1:

djz count3

jmp chmode2

jmp boom3;第二种模式

chmode2:

jmp boom3

end


推荐阅读

史海拾趣

西博臣(CYBERSEN)公司的发展小趣事

作为一家有社会责任感的企业,西博臣积极履行社会责任,关注环境保护和可持续发展。公司采用环保材料和生产工艺,减少生产过程中的能源消耗和废弃物排放。同时,公司还积极参与社会公益活动,为社会做出积极贡献。这些举措不仅体现了公司的社会责任感,也为其赢得了更多客户和合作伙伴的信任和支持。

AKM [Asahi Kasei Microsystems]公司的发展小趣事

西博臣非常重视产品质量和品牌建设。公司建立了严格的质量管理体系,从原材料采购到产品生产、测试、包装等各个环节都进行严格的质量控制。同时,公司还注重品牌形象的塑造和推广,通过参加各类行业展会、举办技术交流会等方式提升品牌知名度和美誉度。

Hong Kong X'Tals Ltd公司的发展小趣事
在高负载或长时间工作的情况下,需要关注LM122的散热问题,以避免过热导致性能下降或损坏。
ESTEK公司的发展小趣事

在电子行业日益注重环保的背景下,ESTEK公司积极响应号召,致力于研发和生产绿色环保的电子产品。公司投入大量资金和资源,研发出了一系列符合环保标准的电子元件和设备。这些产品在市场上受到了广泛欢迎,不仅为公司带来了可观的经济效益,也为环保事业做出了积极贡献。

Fenghua (HK) Electronics Ltd公司的发展小趣事

在技术创新的基础上,Fenghua (HK) Electronics Ltd积极拓展国内外市场。公司参加了多个国际电子展,与全球各地的客户建立了良好的合作关系。同时,公司注重品牌建设,通过广告宣传、赞助活动等方式,提高了品牌知名度和美誉度。这些努力使得公司的产品在国内外市场上占据了越来越大的份额。

Focus公司的发展小趣事

Focus Enhancements, Inc.(根据参考文章中的信息)是一家无晶圆厂集成电路(IC)公司,专注于为家庭影院系统、便携式媒体播放器、智能手机等消费电子设备开发和销售IC解决方案和组件。自1996年以来,该公司凭借其强大的研发团队和敏锐的市场洞察力,不断推出创新产品,赢得了包括微软、东芝、LG、索尼等全球知名OEM厂商的青睐。随着物联网和智能设备的兴起,Focus Enhancements加大了对低功耗、高性能芯片的研发力度,成功拓展了智能家居、可穿戴设备等领域的应用市场。

问答坊 | AI 解惑

D-Link网络视频监控系统信息化方案

网络视频监控的发展经历了三个阶段,早期由安防产品演化而来的闭路视频监控系统是我国第一代模拟视频监控系统。到了九十年代中期,一种基于PC机插卡式的视频监控系统的出现,尽管初步实现了数字化,但由于图像质量、稳定性以及远程传输监控等技术方 ...…

查看全部问答>

AD6学习教程.pdf

AD6学习教程 [ 本帖最后由 mcu_mouse 于 2009-9-16 10:03 编辑 ]…

查看全部问答>

80端口被封,远程监控咋办?

2009年12月20日,中国电信发布公告,称“应工信部要求从12月20号开始,中国电信ADSL宽带业务只提供普通的宽带上网,其用户不能对外提供其他服务,并且工信部没有给出相应的解封时间。” 所谓80端口是为HTTP(HyperTextTransportProtocol,超文本传 ...…

查看全部问答>

EVC应用程序,菜单不能用中文

菜单的caption用中文用不了,IDR_MAINFRAME的caption想用中文,提示无效字符。 子菜单的caption用中文可以输入进去,在PC上编辑显示正常,下载到开发板上就是乱码了。 我开发板是中文系统啊,到底哪里的问题。…

查看全部问答>

DVM数字电压表是什么东东,干什么用的啊?

DVM数字电压表是什么专业的知识啊。 朋友让我帮他写以个这方面的论文,有什么专门这方面的书介绍一下吗,各位大侠给我讲讲啊。谢谢了。 它的原理图是有几个动态显示的数码管组成。芯片有ADC0804芯片,7447芯片,还有8051芯片。…

查看全部问答>

测湿度用什么传感器比较好

如题,我现在要做一个测湿度的系统,但是不能用温湿度一体的芯片,所以想请各位大大给点建议,我该用什么传感器。用89C51单片机如何编程!…

查看全部问答>

usb键盘问题

用stm32 模拟了一个usb接口的键盘,参考的st usb库的例子, 发现发送的时候,pc上接收到一次后会不断的发送, 应该是好像在不断的发送,就像按键一直按着没有松开,但实际上我只发送了一次, 是什么原因呢?是否键盘要做什么特别处理? 实 ...…

查看全部问答>

基于MDK的STM32处理器开发应用

基于MDK的STM32处理器开发应用 内容简介 本书介绍了基于MDK的STM32处理器开发应用。全书共9章,分为4部分。第一部分为基础篇,在讲解Cortex-M3处理器结构的基础上,详细介绍了Cortex-M3处理器的编程模型、总线架构、存储结构、异常处理机制、Thum ...…

查看全部问答>

我的LCD亮不了

我用的是449的芯片,LCD用的是20脚的LCD048,S0到S14连接到449上,另外还有5个COM端,也连接到449上,原先没有外接电阻,亮不了,现在连接了3个330K的电阻后,刚接通电的时候能量下,刚烧进程序的时候也能亮,可是之后就慢慢暗掉。程序是每问题的, ...…

查看全部问答>