单片机STC89C52RC实现时钟(汇编语言)

单片机STC89C52RC实现时钟(汇编语言)

基于STC89C52制作时钟(汇编)7.27

完整代码:

;REGISTER_GROUP0:R0,R1,R2,R3,R4,R5  R6->M R7->S
;REGISTER_GROUP2:R0->H  R3计数=20D	R5R6:延时

	ORG 0000H
	LJMP 0030H

	ORG 000BH
	LJMP T0INTERUPT

	ORG 0030H
INI_TIME: ;开机初始化时间
	SETB RS1
	MOV R0,#00D;H
	CLR RS1
	MOV R6,#00D;M
	MOV R7,#00D;S
	

LED_INIT:
	LCALL BUSY
	CLR P1.0
	CLR P1.1
	SETB P2.5
	MOV P0,#38H
	CLR P2.5
	LCALL DELAY
	
	LCALL BUSY
	CLR P1.0
	CLR P1.1
	SETB P2.5
	MOV P0,#08H
	CLR P2.5
	LCALL DELAY
	
	LCALL BUSY
	CLR P1.0
	CLR P1.1
	SETB P2.5
	MOV P0,#01H
	CLR P2.5
	LCALL DELAY
	
	LCALL BUSY
	CLR P1.0
	CLR P1.1
	SETB P2.5
	MOV P0,#06H
	CLR P2.5
	LCALL DELAY
	
	LCALL BUSY
	CLR P1.0
	CLR P1.1
	SETB P2.5
	MOV P0,#0CH
	CLR P2.5
	LCALL DELAY


T0INIT:
    MOV TMOD,#01H;50MS
    MOV TH0,#4CH
    MOV TL0,#00H
    SETB EA
    SETB ET0
    SETB TR0

DISPLAY:
	;LCALL TRANSFER

	LCALL BUSY
	CLR P1.0
	CLR P1.1
	SETB P2.5
	MOV P0,#83H;#0C0H
	CLR P2.5
	LCALL BUSY
	SETB P1.0
	CLR P1.1
	SETB P2.5
	MOV P0,R0;CHAR
	CLR P2.5

	LCALL BUSY
	CLR P1.0
	CLR P1.1
	SETB P2.5
	MOV P0,#84H;#0C0H
	CLR P2.5
	LCALL BUSY
	SETB P1.0
	CLR P1.1
	SETB P2.5
	MOV P0,R1;CHAR
	CLR P2.5

	LCALL BUSY
	CLR P1.0
	CLR P1.1
	SETB P2.5
	MOV P0,#85H;#0C0H
	CLR P2.5
	LCALL BUSY
	SETB P1.0
	CLR P1.1
	SETB P2.5
	MOV P0,#68H;CHAR
	CLR P2.5

	LCALL BUSY
	CLR P1.0
	CLR P1.1
	SETB P2.5
	MOV P0,#86H;#0C0H
	CLR P2.5
	LCALL BUSY
	SETB P1.0
	CLR P1.1
	SETB P2.5
	MOV P0,R2;CHAR
	CLR P2.5

	LCALL BUSY
	CLR P1.0
	CLR P1.1
	SETB P2.5
	MOV P0,#87H;#0C0H
	CLR P2.5
	LCALL BUSY
	SETB P1.0
	CLR P1.1
	SETB P2.5
	MOV P0,R3;CHAR
	CLR P2.5

	LCALL BUSY
	CLR P1.0
	CLR P1.1
	SETB P2.5
	MOV P0,#88H;#0C0H
	CLR P2.5
	LCALL BUSY
	SETB P1.0
	CLR P1.1
	SETB P2.5
	MOV P0,#6DH;CHAR
	CLR P2.5

	LCALL BUSY
	CLR P1.0
	CLR P1.1
	SETB P2.5
	MOV P0,#89H;#0C0H
	CLR P2.5
	LCALL BUSY
	SETB P1.0
	CLR P1.1
	SETB P2.5
	MOV P0,R4;CHAR
	CLR P2.5

	LCALL BUSY
	CLR P1.0
	CLR P1.1
	SETB P2.5
	MOV P0,#8AH;#0C0H
	CLR P2.5
	LCALL BUSY
	SETB P1.0
	CLR P1.1
	SETB P2.5
	MOV P0,R5;CHAR
	CLR P2.5

	LCALL BUSY
	CLR P1.0
	CLR P1.1
	SETB P2.5
	MOV P0,#8BH;#0C0H
	CLR P2.5
	LCALL BUSY
	SETB P1.0
	CLR P1.1
	SETB P2.5
	MOV P0,#73H;CHAR
	CLR P2.5
	
	LJMP DISPLAY

BUSY:
	MOV P0,#0FFH
	CLR P1.0
	SETB P1.1
	SETB P2.5
	NOP
	NOP
	NOP
	NOP
	NOP
	MOV A,P0
	ANL A,#80H
	JNZ BUSY
	RET


DELAY:
	SETB RS1
    MOV R6,#0FH
DL0:
    MOV R5,#98H
    DJNZ R5,$
    DJNZ R6,DL0
	CLR RS1
    RET

T0INTERUPT:
	MOV TH0,#4CH
    MOV TL0,#00H
	SETB RS1
	DJNZ R3,C1
	MOV R3,#20D
	CLR RS1
	INC R7
	CJNE R7,#60D,C1;不相等转移
	MOV R7,#00D
	INC R6
	CJNE R6,#60D,C1
	MOV R6,#00H
	SETB RS1
	INC R0
	CJNE R0,#24D,C1
	MOV R0,#00D
C1:	LCALL TRANSFER
	CLR RS1
	RETI

TRANSFER:
	SETB RS1
	MOV A,R0
	MOV B,#10D
	DIV AB
	CLR RS1
	MOV R0,A
	MOV A,B
	MOV R1,A

	MOV A,R6
	MOV B,#10D
	DIV AB
	MOV R2,A
	MOV A,B
	MOV R3,A

	MOV A,R7
	MOV B,#10D
	DIV AB
	MOV R4,A
	MOV A,B
	MOV R5,A

	MOV A,R0
	ADD A,#30H
	MOV R0,A

	MOV A,R1
	ADD A,#30H
	MOV R1,A

	MOV A,R2
	ADD A,#30H
	MOV R2,A

	MOV A,R3
	ADD A,#30H
	MOV R3,A

	MOV A,R4
	ADD A,#30H
	MOV R4,A

	MOV A,R5
	ADD A,#30H
	MOV R5,A

	RET

	END
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值