历史上的今天
今天是: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
上一篇:大功率轮廓灯跳机同步2回路源程序
下一篇:LED游泳池灯源程序
史海拾趣
|
一、前言 随着系统功率预算的不断紧缩,迫切需要新型低功率元器件。对通信基础设施而言,电路板冷却、机箱体积小型化以及系统可靠性在系统设计中都起着重要的作用。对e-应用,电池寿命、热耗散和小体积尺寸是主要的设计难点。选用智 ...… 查看全部问答> |
|
wince下用IImage显示jpeg图片后不能删除图片的问题 wince下用IImage显示jpeg图片,不退出程序,结果不能删除该jpg文件,这是怎么回事呀? 只要执行过一片test() 函数, \\\\NandFlash\\\\test.jpg 文件就不能删除,删除时出现“文件共享,不能删除” 难道是我没释放什么吗? 函数如下: void tes ...… 查看全部问答> |
|
想找个兼职,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里使用这个 ...… 查看全部问答> |
|
用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无法连接STM32F103C8T6的目标板,显示的是 JTAG Commnication Failure 测量了 RESET,nJRST,TDO,TDI,TMS 信号是3.3的高电平 TCK RTCK电平时低电平。 VDD VDDA VSS VSSA 都接到了 相应的电源和地上。 BOOT0 BOO ...… 查看全部问答> |
|
本帖最后由 paulhyde 于 2014-9-15 09:04 编辑 1.1任务设计并制作一个水位监测与控制装置,1.2 要求1. 基本要求(1)通过键盘可以设定B瓶里的液位(0-25cm内的任意值),并通过控制电磁阀(或类似于电磁阀的装置)使B瓶的液位达到设定值。(2)液 ...… 查看全部问答> |
|
DIY 有关 LED应急灯的 注意事项 1、一些LED应急电源产品,停电后把电池组储存的电能逆变器为市电220V,相当于市电的延续,那么驱动电源是必须要存在的。 2、一部分LED应急电源产品,在停电后的输出是直流低电压,通用在20---80V之 ...… 查看全部问答> |




