单片机打铃器设计
序*************************************
;*
;*功能:从以EEARD(r18:r17)内容为地址的EEPRON单元读区内容送EEDRD(r16)寄存器。
;*
;****程序段
EERead: sbic EECR,EEWE
rjmp EERead
out EEARH,EEardh
out EEARL,EEard
sbi EECR,EERE
sbi EECR,EERE
in EEdrd,EEDR
ret
;****6字节SRAM内容传送子程序************************************************************
;*
;* 功能:将SRAM内连续6字节由BLOCK1传送到BLOCK2
;* x---欲传送6字节起始地址(SRAM)指针
;* y---欲放置6字节起始地址(SRAM)指针
;*
;****程序段
ram6ram:push temp1
push temp2
ldi temp1,$06
ramd1: ld temp2,x+
st y+,temp2
dec temp1
brne ramd1
pop temp2
pop temp1
ret
;****8位二进制数转3位BCD数子程序********************************************************
;*
;*功能:把一个8位无符号二进制数转换为3位BCD码数。
;*入口:r16---内装8位无符号二进制数。
;*出口:BCD码放在r2:r3:r4,r2存放百位。
;*
;****程序段
bt push r16
clr r2
clr r3
clr r4
rjmp bto2
bto1: inc r2
bto2: subi r16,100
brpl bto1
ldi temp,100
add r16,temp
rjmp bto4
bto3: inc r3
bto4: subi r16,10
brpl bto3
ldi temp,10
add r16,temp
mov r4,r16
pop r16
ret
;****时钟0中断服务程序******************************************************
.org $0bf0
TIM0_OVF: push temp
ldi temp,256-195
out tcnt0,temp ;重装T0时间常数
inc cntms
mov temp,cntms
cpi temp,40
brne timecunt
clr cntms
inc second
mov temp,second
cpi temp,60
brne timecunt
clr second
ldi TIM0INT,1
inc minute
mov temp,minute
cpi temp,60
brne timecunt
clr minute
inc hour
mov temp,hour
cpi temp,24
brne timecunt
clr hour
timecunt: ldi xl, low(TIMEDIS)
clr xh
mov r16,hour
rcall bto
st x+,r3
st x+,r4
mov r16,minute
rcall bto
st x+,r3
st x+,r4
mov r16,second
rcall bto
st x+,r3
st x+,r4
pop temp
reti
;****字形表**********************************************
.cseg
.org DISTBL
.dw 0x003f,0x0006,0x005b,0x004f,0x0066,0x006d,0x007d,0x0007,0x007f,0x006f
.dw 0x0077,0x007c,0x0039,0x005e,0x0079,0x0071,0x0073,0x0076,0x0058,0x0038
.dw 0x005c,0x0067,0x0050,0x006e,0x0078,0x0000,0x0054,0x0040,0x0074,0x0000
- FPGA的DSP性能揭秘(06-16)
- 基于单片机通用引脚的软件UART设计(10-16)
- 分时操作系统思想在单片机中的具体应用 (10-30)
- 基于AT89C51+DSP的双CPU伺服运动控制器的研究(05-26)
- 关于RTX51 TINY的分析与探讨(05-30)
- 基于MC9S12DGl28单片机的智能寻迹车设计(04-03)
