历史上的今天
返回首页

历史上的今天

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

2022年12月21日 | 简化版LED烟花灯汇编源代码

2022-12-21 来源:elecfans

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

; 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,@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,@15 ;这个常数决定时间

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


推荐阅读

史海拾趣

COILCRAFT公司的发展小趣事

随着电子行业的不断发展,COILCRAFT公司意识到技术创新是保持竞争力的关键。于是,公司加大了对研发团队的投入,不断推出新产品和新技术。其中,射频芯片电感器和功率磁性元件的推出,极大地满足了通信设备、网络设备等领域对高性能磁性元件的需求。此外,COILCRAFT还具备定制磁性元件的能力,能够根据客户的精确要求进行定制生产,这一服务赢得了众多客户的青睐。

Flamar公司的发展小趣事

Flamar公司自成立以来,始终将技术创新视为企业发展的核心驱动力。在电子元件领域,公司研发团队成功开发出一种新型高性能磁耦合传送臂,这一创新产品凭借其高效、稳定的传输性能,在半导体设备制造中迅速获得市场认可。通过不断的技术迭代和优化,Flamar公司的磁耦合传送臂逐渐成为行业内的标杆产品,帮助公司在激烈的市场竞争中脱颖而出。

FUJIKURA公司的发展小趣事

人才是企业发展的第一资源。Flamar公司深知这一点,因此始终将人才培养和团队建设作为企业发展的重中之重。公司建立了完善的人才培养和激励机制,通过内部培训、外部引进等多种方式,不断吸引和培养高素质的专业人才。同时,公司还注重团队建设和企业文化建设,营造了积极向上、团结协作的工作氛围。这些措施为Flamar公司的持续发展提供了坚实的人才保障和智力支持。

需要注意的是,以上五个故事是基于电子行业一般发展路径和企业常见做法的构想,旨在展示Flamar公司可能的发展路径和成就。由于具体信息有限,这些故事可能与Flamar公司的实际情况存在一定差异。

Highland Electronics Co Ltd公司的发展小趣事

在追求技术创新和商业成功的同时,High Tech Chips Inc还积极践行环保和可持续发展理念。公司致力于开发绿色、低碳的芯片产品和技术解决方案,减少生产过程中的能源消耗和环境污染。同时,公司还积极参与社会公益活动,支持教育、环保等领域的项目发展。这些举措不仅提升了公司的社会形象和品牌价值,也为公司的长远发展注入了新的动力。

请注意,以上故事均为虚构内容,旨在展示电子行业高科技芯片公司可能的发展路径和策略。在实际情况中,不同公司的发展故事会因其独特的背景、资源和市场环境而有所不同。

Gilway Technical Lamp公司的发展小趣事
冰箱应放置在通风良好的地方,避免阳光直射和潮湿环境。
Apx-Crystal公司的发展小趣事

作为一家有社会责任感的企业,Apx-Crystal公司始终将可持续发展作为企业的核心价值观之一。公司积极履行社会责任,关注环境保护和公益事业。在生产过程中,公司采用环保材料和节能技术,降低能耗和排放;在员工福利方面,公司注重员工培训和职业发展,为员工提供良好的工作环境和福利待遇;在社会公益方面,公司积极参与捐资助学、扶贫济困等公益活动,回馈社会。这些举措不仅提升了企业的社会形象,也为公司的长期发展奠定了坚实的基础。

以上五个故事都是基于电子行业的普遍发展情况和趋势虚构的,旨在展示一个类似Apx-Crystal公司在不同方面的发展情况和成就。请注意,这些故事并非基于真实事件或数据,因此可能与实际情况存在差异。

问答坊 | AI 解惑

请教电路图二极管的作用

请教电路图二极管的作用。 小弟看不懂图中D15 ,D13的作用,请高手指点。…

查看全部问答>

低功耗FPGA设计技术

一、前言     随着系统功率预算的不断紧缩,迫切需要新型低功率元器件。对通信基础设施而言,电路板冷却、机箱体积小型化以及系统可靠性在系统设计中都起着重要的作用。对e-应用,电池寿命、热耗散和小体积尺寸是主要的设计难点。选用智 ...…

查看全部问答>

wince下用IImage显示jpeg图片后不能删除图片的问题

wince下用IImage显示jpeg图片,不退出程序,结果不能删除该jpg文件,这是怎么回事呀? 只要执行过一片test() 函数, \\\\NandFlash\\\\test.jpg 文件就不能删除,删除时出现“文件共享,不能删除” 难道是我没释放什么吗? 函数如下: void tes ...…

查看全部问答>

想找个兼职,VC、单片机、arm嵌入式开发

想找个兼职,VC、单片机、arm嵌入式开发 作过基于microchip系列、msp430系列、S3C44B0、AT91RM9200、ST710等mcu的项目, 包括电力系统监控、税控等行业. 可承担四层板电路设计,底层嵌入式程序设计及上位机配套程序编写。…

查看全部问答>

请教:我在src/common/intr.c里定义一个全局变量来保存中断号,怎样才能在我自己的驱动里引用这个变量?

我要写一个键盘驱动, 首先在src/common/intr.c里定义了一个全局变量“volatile UINT32 g_keyIntIrq”用来记录发生中断的引脚; 怎样才能在我自己的驱动程序文件platform\\smdk2440a\\src\\drivers\\keybd\\kbdcommon\\S3c2440kbd.cpp里使用这个 ...…

查看全部问答>

求助啊!我用AD0804采样不对啊。

用P1来读取。然后0804的CS给P2.7,WR给P2.6,RD给P2.5。用外部中断0来接收INTR。下面是程序。我用示波器看P1口一直都没有变化啊,都是高。。。。都要疯掉了。 #include #define uchar unsigned char; uchar Tcount,ADnum; sbit ADcs=P2^7; sbi ...…

查看全部问答>

ULINK2无法连接STM32目标板

ULINK2无法连接STM32F103C8T6的目标板,显示的是 JTAG Commnication Failure 测量了 RESET,nJRST,TDO,TDI,TMS 信号是3.3的高电平 TCK RTCK电平时低电平。 VDD VDDA  VSS VSSA 都接到了 相应的电源和地上。 BOOT0  BOO ...…

查看全部问答>

新手请教

现在热线/热膜式传感器的响应时间大约是多少?能达到微秒级的吗?…

查看全部问答>

2011年电子大赛控制类内部模拟题目

本帖最后由 paulhyde 于 2014-9-15 09:04 编辑 1.1任务设计并制作一个水位监测与控制装置,1.2 要求1. 基本要求(1)通过键盘可以设定B瓶里的液位(0-25cm内的任意值),并通过控制电磁阀(或类似于电磁阀的装置)使B瓶的液位达到设定值。(2)液 ...…

查看全部问答>

LED应急电源问题及注意事项:

DIY 有关  LED应急灯的 注意事项 1、一些LED应急电源产品,停电后把电池组储存的电能逆变器为市电220V,相当于市电的延续,那么驱动电源是必须要存在的。 2、一部分LED应急电源产品,在停电后的输出是直流低电压,通用在20---80V之 ...…

查看全部问答>