返回主页 单片机教程XL2000开发板 单片机学习 自制编程器 单片机资料 软件下载 电子技术产品介绍如何购买 进入论坛

51单片机学习网热心版主单片东东,收集整理的单片机教程课程(例子程序, 特别推荐!)转载请保留连接!
单片机简介与单片机的发展历史I/O 口功能实例流水灯和方波试验
定时器实例 (1秒报警,200hz输出 200-250变化输出)

数码管0—9999 的循环显示

ADC0809模拟输入电压,在数码管上显示出来

ADC0809输入的两个不同电压数相加显示出来

软件滤波十六进制六位数加法(数码显示)求六位和中的最大值和最小值(数码显示)
求减去最大和最小值后的值(数码显示)除4所得软件滤波值(数码显示)
软件模拟一个振动传感器软件搜频的全过程在显示频率输出的同时显示AD值(数码显示)
过程检定(数码显示)

DA 转换三角波 正旋波 梯形波(dac0832)

串口通信,看到画面——“我爱单片机”。

按键数显,数码管显示加一
PWM码简介及解码原理--红外遥控原理与解码程序
智能定时的4位电子钟(带定时控制)智能红外工业控制器

51单片机学习网热心版主单片东东,收集整理的单片机教程课程(例子程序, 特别推荐!)转载请保留连接!

<>如果您有任何不明白的地方请参加51单片机学习网论坛讨论

 

2.2 智能红外工业控制器

程序介绍:这个产品是通过遥控器控制定时时间来决P1.0口输出高电平和低电平的时间,在P1.0口接一个继

电器后,从而控制电磁阀开和关,以达到对石油含水量的定时智能排放。现已应用在上海金山炼油厂,反映良好。

本实验仪完全模拟了这个产品,它的详细操作请参照附一(以用于上海金山炼油厂的产品说明)。

程序实例(honwai.asm):

ORG 0000H

AJMP MAIN

ORG 000BH

AJMP DIN0 ;TIME

ORG 00013H

AJMP INT

106

MAIN:

;DATA DEFINE////////////////////////////////////////

ON_MINUTE_LOW EQU 30H

ON_MINUTE_HIGH EQU 31H

ON_HOUR_LOW EQU 32H

ON_HOUR_HIGH EQU 33H

OFF_MINUTE_LOW EQU 34H

OFF_MINUTE_HIGH EQU 35H

OFF_HOUR_LOW EQU 36H

OFF_HOUR_HIGH EQU 37H

DIS_MINUTE_LOW EQU 38H

DIS_MINUTE_HIGH EQU 39H

DIS_HOUR_LOW EQU 40H

DIS_HOUR_HIGH EQU 41H

TIMES_ADD_NUMBER EQU 42H

TIMEM_ADD_NUMBER EQU 3FH

INTERRUPT_NUMBER EQU 43H

INTSET_FLAG EQU 44H

ETTYPE_FLAG EQU 4FH

BL EQU 3EH

BL1 EQU 4EH

SET_ON_MLOW EQU 3AH

SET_ON_MHIGH EQU 3BH

SET_ON_HLOW EQU 3CH

SET_ON_HHIGH EQU 3DH

SET_OFF_MLOW EQU 4AH

SET_OFF_MHIGH EQU 4BH

SET_OFF_HLOW EQU 4CH

107

SET_OFF_HHIGH EQU 4DH

;//////////////////////////////////////////////////

;DATA GIVE FIRST NUMBER//////////////////////////

MOV ON_MINUTE_LOW,#00H

MOV ON_MINUTE_HIGH,#02H

MOV ON_HOUR_LOW,#00H

MOV ON_HOUR_HIGH,#00H

MOV OFF_MINUTE_LOW,#00H

MOV OFF_MINUTE_HIGH,#06H

MOV OFF_HOUR_LOW,#03H

MOV OFF_HOUR_HIGH,#00H

MOV DIS_MINUTE_LOW,#00H

MOV DIS_MINUTE_HIGH,#00H

MOV DIS_HOUR_LOW,#00H

MOV DIS_HOUR_HIGH,#00H

MOV TIMES_ADD_NUMBER,#00H

MOV TIMEM_ADD_NUMBER,#00H

MOV INTERRUPT_NUMBER,#00H

MOV INTSET_FLAG,#00H

MOV SETTYPE_FLAG,#00H

MOV BL,#00H

MOV BL1,#00H

MOV SET_ON_MLOW,#00H

MOV SET_ON_MHIGH,#00H

MOV SET_ON_HLOW,#00H

MOV SET_ON_HHIGH,#00H

MOV SET_OFF_MLOW,#00H

MOV SET_OFF_MHIGH,#00H

108

MOV SET_OFF_HLOW,#00H

MOV SET_OFF_HHIGH,#00H

;//////////////////////////////////////////////////

MOV TMOD,#00010001B

MOV TL0,#0AFH

MOV TH0,#3CH

SETB IT1

SETB EX1

SETB TR0

SETB ET0

SETB PT0

SETB EA

CLR P1.0

;//////////////////////////////////////////////////

;DISPLAY///////////////////////////////////////////

DISPLAY:

MOV BL1,#00H

MOV A,DIS_MINUTE_LOW

MOV DPTR,#SETTAB

MOVC A,@A+DPTR

MOV SBUF,A

D1: JNB TI,D1

CLR TI

MOV A,DIS_MINUTE_HIGH

MOV DPTR,#SETTAB

MOVC A,@A+DPTR

MOV SBUF,A

D2: JNB TI,D2

109

CLR TI

MOV A,DIS_HOUR_LOW

MOV DPTR,#SETTAB

MOVC A,@A+DPTR

MOV SBUF,A

D3: JNB TI,D3

CLR TI

MOV A,DIS_HOUR_HIGH

MOV DPTR,#SETTAB

MOVC A,@A+DPTR

MOV SBUF,A

D4: JNB TI,D4

CLR TI

LCALL DELAY1

;INTSETFLAG//////////////////////////////////

MOV A,INTSET_FLAG

CJNE A,#00H,AONFE

AJMP DISP

AONFE: CJNE A,#01H,AONSH

AJMP ONFE

AONSH: CJNE A,#02H,AOFFE

AJMP ONSH

AOFFE: CJNE A,#03H,AOFSH

AJMP OFFFE

AOFSH: AJMP OFFSH

;/////////////////////////////////////////////

DISP: JNB P1.0,DISON

AJMP DISOFF

110

DISON: MOV A,#0ECH

MOV SBUF,A

D8: JNB TI,D8

CLR TI

MOV A,#0FCH

MOV SBUF,A

D7: JNB TI,D7

CLR TI

MOV A,#00H

MOV SBUF,A

D6: JNB TI,D6

CLR TI

MOV A,#00H

MOV SBUF,A

D5: JNB TI,D5

CLR TI

LCALL DELAY1

;INTSETFLAG////////////////////////////////////////

MOV A,INTSET_FLAG

CJNE A,#00H,BONFE

AJMP D1ISP

BONFE: CJNE A,#01H,BONSH

AJMP ONFE

BONSH: CJNE A,#02H,BOFFE

AJMP ONSH

BOFFE: CJNE A,#03H,BOFSH

AJMP OFFFE

BOFSH: AJMP OFFSH

111

;/////////////////////////////////////////////

D1ISP: AJMP DISPLAY

DISOFF:

MOV A,#8EH

MOV SBUF,A

D12: JNB TI,D12

CLR TI

MOV A,#8EH

MOV SBUF,A

D11: JNB TI,D11

CLR TI

MOV A,#0FCH

MOV SBUF,A

D10: JNB TI,D10

CLR TI

MOV A,#00H

MOV SBUF,A

D9: JNB TI,D9

CLR TI

LCALL DELAY1

LCALL DELAY1

;INTSETFLAG///////////////////////////////////

STATUS: MOV A,INTSET_FLAG

CJNE A,#00H,CONFE

AJMP D2ISP

CONFE: CJNE A,#01H,CONSH

AJMP ONFE

CONSH: CJNE A,#02H,COFFE

112

AJMP ONSH

COFFE: CJNE A,#03H,COFSH

AJMP OFFFE

COFSH: AJMP OFFSH

;/////////////////////////////////////////////

D2ISP: AJMP DISPLAY

;//////////////////////////////////////////////////

;STATUS ONFEN///////////////////////////////////////

ONFE:

MOV A,#9EH

MOV SBUF,A

DD1: JNB TI,DD1

CLR TI ;E

MOV A,#8EH

MOV SBUF,A

DD2: JNB TI,DD2

CLR TI ;F

MOV A,#0ECH

MOV SBUF,A

DD3: JNB TI,DD3

CLR TI ;N

MOV A,#0FCH

MOV SBUF,A

DD4: JNB TI,DD4

CLR TI ;O

LCALL DELAY2

MOV A,BL1

CJNE A,#01H,ONFE

113

MOV A,SETTYPE_FLAG

CJNE A,#01H,STA

AJMP SETONFEN

STA: AJMP STATUS

;//////////////////////////////////////////////////

;STATUS ON SH/////////////////////////////////////

ONSH:

;display onus//////////////////////////////////////

MOV A,#6EH

MOV SBUF,A

DD8: JNB TI,DD8

CLR TI ;H

MOV A,#0B6H

MOV SBUF,A

DD7: JNB TI,DD7

CLR TI ;S

MOV A,#0ECH

MOV SBUF,A

DD6: JNB TI,DD6

CLR TI ;N

MOV A,#0FCH

MOV SBUF,A

DD5: JNB TI,DD5

CLR TI ;O

LCALL DELAY2

MOV A,BL1

CJNE A,#01H,ONSH

MOV A,SETTYPE_FLAG

114

CJNE A,#01H,STA1

AJMP SETONSH

STA1:

AJMP STATUS

;//////////////////////////////////////////////////

;STATUS OFF FE///////////////////////////////////

OFFFE:

;display ofad///////////////////////////////////////

MOV A,#09EH

MOV SBUF,A

DD10 : JNB TI,DD10

CLR TI ;E

MOV A,#8EH

MOV SBUF,A

DD9: JNB TI,DD9

CLR TI ;F

MOV A,#8EH

MOV SBUF,A

DD12: JNB TI,DD12

CLR TI ;F

MOV A,#0FCH

MOV SBUF,A

DD11: JNB TI,DD11

CLR TI ;O

LCALL DELAY

MOV A,BL1

CJNE A,#01H,OFFFE

MOV A,SETTYPE_FLAG

115

CJNE A,#01H,STA2

AJMP SETOFFEN

STA2:

AJMP STATUS

;//////////////////////////////////////////////////

;STATUS OFF SH///////////////////////////////////

OFFSH:

MOV A,#6EH

MOV SBUF,A

DD14: JNB TI,DD14

CLR TI ;H

MOV A,#0B6H

MOV SBUF,A

DD13: JNB TI,DD13

CLR TI ;S

MOV A,#8EH

MOV SBUF,A

DD16: JNB TI,DD16

CLR TI ;F

MOV A,#0FCH

MOV SBUF,A

DD15: JNB TI,DD15

CLR TI ;O

LCALL DELAY2

MOV A,BL1

CJNE A,#01H,OFFSH

MOV A,SETTYPE_FLAG

CJNE A,#01H,STA3

116

AJMP SETOFFSH

STA3:

AJMP STATUS

;/////////////////////////////////////////////

SETONFEN:

CLR TR0

MOV C,P1.0

JNC FI

AJMP FI1

FI: MOV DIS_MINUTE_LOW,#00H

MOV DIS_MINUTE_HIGH,#00H

MOV DIS_HOUR_LOW,#00H

MOV DIS_HOUR_HIGH,#00H

FI1: MOV SET_ON_MLOW,#00H

MOV SET_ON_MHIGH,#00H

SETONFEN2:

INC SET_ON_MLO

MOV A,SET_ON_MLOW

CJNE A,#0AH,CJ

MOV SET_ON_MLOW,#00H

INC SET_ON_MHIGH

MOV A,SET_ON_MHIGH

CJNE A,#0AH,CJ

MOV SET_ON_MHIGH,#00H

CJ:

MOV A,SET_ON_MLOW

MOV DPTR,#SETTAB

MOVC A,@A+DPTR

117

MOV SBUF,A

D13: JNB TI,D13

CLR TI

MOV A,SET_ON_MHIGH

MOV DPTR,#SETTAB

MOVC A,@A+DPTR

MOV SBUF,A

D14: JNB TI,D14

CLR TI

MOV A,SET_ON_HLOW

MOV DPTR,#SETTAB

MOVC A,@A+DPTR

MOV SBUF,A

D15: JNB TI,D15

CLR TI

MOV A,SET_ON_HHIGH

MOV DPTR,#SETTAB

MOVC A,@A+DPTR

MOV SBUF,A

D16: JNB TI,D16

CLR TI

LCALL DELAY1

LCALL DELAY1

MOV ON_MINUTE_LOW,SET_ON_MLOW

MOV ON_MINUTE_HIGH,SET_ON_MHIGH

MOV ON_HOUR_LOW,SET_ON_HLOW

MOV ON_HOUR_HIGH,SET_ON_HHIGH

MOV A,SETTYPE_FLAG

118

CJNE A,#00H,SETONFEN1

SETB TR0

AJMP DISPLAY

SETONFEN1:

AJMP SETONFEN2

SETONSH:

CLR TR0

MOV C,P1.0

JNC F2

AJMP FI2

F2: MOV DIS_MINUTE_LOW,#00H

MOV DIS_MINUTE_HIGH,#00H

MOV DIS_HOUR_LOW,#00H

MOV DIS_HOUR_HIGH,#00

FI2: MOV SET_ON_HLOW,#00H

MOV SET_ON_HHIGH,#00H

SETONSH2:

INC SET_ON_HLOW

MOV A,SET_ON_HLOW

CJNE A,#0AH,CJ1

MOV SET_ON_HLOW,#00H

INC SET_ON_HHIGH

MOV A,SET_ON_HHIGH

CJNE A,#0AH,CJ1

MOV SET_ON_HHIGH,#00H

CJ1:

MOV A,SET_ON_MLOW

MOV DPTR,#SETTAB

119

MOVC A,@A+DPTR

MOV SBUF,A

D17: JNB TI,D17

CLR TI

MOV A,SET_ON_MHIGH

MOV DPTR,#SETTAB

MOVC A,@A+DPTR

MOV SBUF,A

D18: JNB TI,D18

CLR TI

MOV A,SET_ON_HLOW

MOV DPTR,#SETTAB

MOVC A,@A+DPTR

MOV SBUF,A

D19: JNB TI,D19

CLR TI

MOV A,SET_ON_HHIGH

MOV DPTR,#SETTAB

MOVC A,@A+DPTR

MOV SBUF,A

D20: JNB TI,D2

CLR TI

LCALL DELAY1

LCALL DELAY1

MOV ON_MINUTE_LOW,SET_ON_MLOW

MOV ON_MINUTE_HIGH,SET_ON_MHIGH

MOV ON_HOUR_LOW,SET_ON_HLOW

MOV ON_HOUR_HIGH,SET_ON_HHIGH

120

MOV A,SETTYPE_FLAG

CJNE A,#00H,SETONSH1

SETB TR0

AJMP DISPLAY

SETONSH1:

AJMP SETONSH2

SETOFFEN:

CLR TR0

MOV C,P1.0

JC F3

AJMP FI3

F3: MOV DIS_MINUTE_LOW,#00H

MOV DIS_MINUTE_HIGH,#00H

MOV DIS_HOUR_LOW,#00H

MOV DIS_HOUR_HIGH,#00

FI3: MOV SET_OFF_MLOW,#00H

MOV SET_OFF_MHIGH,#00H

SETOFFEN2:

INC SET_OFF_MLOW

MOV A,SET_OFF_MLOW

CJNE A,#0AH,CJJ1

MOV SET_OFF_MLOW,#00H

INC SET_OFF_MHIGH

MOV A,SET_OFF_MHIGH

CJNE A,#0AH,CJJ1

MOV SET_OFF_MHIGH,#00H

121

CJJ1:

MOV A,SET_OFF_MLOW

MOV DPTR,#SETTAB

MOVC A,@A+DPTR

MOV SBUF,A

D21: JNB TI,D2

CLR TI

MOV A,SET_OFF_MHIGH

MOV DPTR,#SETTA

MOVC A,@A+DPTR

MOV SBUF,A

D22: JNB TI,D22

CLR TI

MOV A,SET_OFF_HLOW

MOV DPTR,#SETTAB

MOVC A,@A+DPTR

MOV SBUF,A

D23: JNB TI,D23

CLR TI

MOV A,SET_OFF_HHIGH

MOV DPTR,#SETTAB

MOVC A,@A+DPTR

MOV SBUF,A

D24: JNB TI,D24

CLR TI

LCALL DELAY1

LCALL DELAY1

MOV OFF_MINUTE_LOW,SET_OFF_MLOW

122

MOV OFF_MINUTE_HIGH,SET_OFF_MHIGH

MOV OFF_HOUR_LOW,SET_OFF_HLOW

MOV OFF_HOUR_HIGH,SET_OFF_HHIGH

MOV A,SETTYPE_FLAG

CJNE A,#00H,SETOFFEN1

SETB TR0

AJMP DISPLAY

SETOFFEN1:

AJMP SETOFFEN2

SETOFFSH:

CLR TR0

MOV C,P1.0

JC F4

AJMP FI4

F4: MOV DIS_MINUTE_LOW,#00H

MOV DIS_MINUTE_HIGH,#00H

MOV DIS_HOUR_LOW,#00H

MOV DIS_HOUR_HIGH,#00

FI4: MOV SET_OFF_HLOW,#00H

MOV SET_OFF_HHIGH,#00H

SETOFFSH2:

INC SET_OFF_HLOW

MOV A,SET_OFF_HLOW

CJNE A,#0AH,CJJJ1

MOV 4CH,#00H

INC SET_OFF_HHIGH

MOV A,SET_OFF_HHIGH

CJNE A,#0AH,CJJJ1

123

MOV SET_OFF_HHIGH,#00H

CJJJ1:

MOV A,SET_OFF_MLOW

MOV DPTR,#SETTAB

MOVC A,@A+DPTR

MOV SBUF,A

D25: JNB TI,D25

CLR TI

MOV A,SET_OFF_MHIGH

MOV DPTR,#SETTAB

MOVC A,@A+DPTR

MOV SBUF,A

D26: JNB TI,D26

CLR TI

MOV A,SET_OFF_HLOW

MOV DPTR,#SETTAB

MOVC A,@A+DPTR

MOV SBUF,A

D27: JNB TI,D27

CLR TI

MOV A,SET_OFF_HHIGH

MOV DPTR,#SETTAB

MOVC A,@A+DPTR

MOV SBUF,A

D28: JNB TI,D28

CLR TI

LCALL DELAY1

LCALL DELAY1

124

MOV OFF_MINUTE_LOW,SET_OFF_MLOW

MOV OFF_MINUTE_HIGH,SET_OFF_MHIGH

MOV OFF_HOUR_LOW,SET_OFF_HLOW

MOV OFF_HOUR_HIGH,SET_OFF_HHIGH

MOV A,SETTYPE_FLAG

CJNE A,#00H,SETOFFSH1

SETB TR0

AJMP DISPLAY

SETOFFSH1:

AJMP SETOFFSH2

;TIME/////////////////////////////////////////

DIN0:

PUSH ACC

INC TIMES_ADD_NUMBER

MOV A,TIMES_ADD_NUMBER

CJNE A,#19,ONRETT

JNB P1.0,SECOND

MOV TIMES_ADD_NUMBER,#00H

INC TIMEM_ADD_NUMBER

MOV A,TIMEM_ADD_NUMBER

CJNE A,#60,ONRETT

MOV TIMEM_ADD_NUMBER,#00H

AJMP DISADD

SECOND: MOV TIMES_ADD_NUMBER,#00H

AJMP DISADD

ONRETT: AJMP ONRET

DISADD: INC DIS_MINUTE_LOW

MOV A,DIS_MINUTE_LOW

125

CJNE A,#0AH,ONRE

MOV DIS_MINUTE_LOW,#00H

INC DIS_MINUTE_HIGH

MOV A,DIS_MINUTE_HIGH

CJNE A,#0AH,ONRE

MOV DIS_MINUTE_HIGH,#00H

INC DIS_HOUR_LOW

MOV A,DIS_HOUR_LOW

CJNE A,#0AH,ONRE

MOV DIS_HOUR_LOW,#00H

INC DIS_HOUR_HIGH

MOV A,DIS_HOUR_HIGH

CJNE A,#0AH,ONRE

MOV DIS_HOUR_HIGH,#00H

ONRE:

JB P1.0,ONRE2

AJMP ONRE1

ONRE2: MOV A,DIS_MINUTE_LOW

CJNE A,OFF_MINUTE_LOW,ONRET

MOV A,DIS_MINUTE_HIGH

CJNE A,OFF_MINUTE_HIGH,ONRET

MOV A,DIS_HOUR_LOW

CJNE A,OFF_HOUR_LOW,ONRET

MOV A,DIS_HOUR_HIGH

CJNE A,OFF_HOUR_HIGH,ONRET

CLR P1.0

MOV DIS_MINUTE_LOW,#00H

MOV DIS_MINUTE_HIGH,#00H

126

MOV DIS_HOUR_LOW,#00H

MOV DIS_HOUR_HIGH,#00H

AJMP ONRET

ONRE1: MOV A,DIS_MINUTE_LOW

CJNE A,ON_MINUTE_LOW,ONRET

MOV A,DIS_MINUTE_HIGH

CJNE A,ON_MINUTE_HIGH,ONRET

MOV A,DIS_HOUR_LOW

CJNE A,ON_HOUR_LOW,ONRET

MOV A,DIS_HOUR_HIGH

CJNE A,ON_HOUR_HIGH,ONRET

SETB P1.0

MOV DIS_MINUTE_LOW,#00H

MOV DIS_MINUTE_HIGH,#00H

MOV DIS_HOUR_LOW,#00H

MOV DIS_HOUR_HIGH,#00H

ONRET: MOV TL0,#0AFH

MOV TH0,#3CH

RE: POP ACC

RETI

;/////////////////////////////////////////////

;INTERRUPT////////////////////////////////////

INT: ;Interrupt program

;GET KEY NUMBER///////////////////////////

CLR EA ;OFF ALL Interuppt

PUSH ACC

MOV R6,#10

SB: ACALL YS1 ;DELAY 882us

127

JB P3.3,DISPL ;High break

DJNZ R6,SB ;DELAY 8820us

JNB P3.3,$ ;Wait high

volgate,BIKAI 9ms low volgate

ACALL YS2 ;DELAY

4.74ms,BIKAI 4.5ms JIEGUOMA

MOV R7,#16 ;(HULUE 16BIT

SYSTEM DATA)

JJJJA: JNB P3.3,$

LCALL YS1

MOV C,P3.3

JNC UUUA

LCALL YS3 ;DELAY 1ms

UUUA: DJNZ R7,JJJJA

MOV R1,#1AH

MOV R2,#2

PP: MOV R3,#8

JJJJ: JNB P3.3,$

LCALL YS1

MOV C,P3.3

JNC UUU

LCALL YS3

UUU: MOV A,@R1

RRC A

MOV @R1,A

DJNZ R3,JJJJ

INC R1

DJNZ R2,PP

128

MOV A,1AH

CPL A

CJNE A,1BH,DISPL

MOV 43H,1AH

MOV A,1AH

;/////////////////////////////////////////////

CJNE A,#041H,CJN3

MOV INTSET_FLAG,#00H

MOV SETTYPE_FLAG,#00H

MOV BL1,#01H

AJMP EXIT

CJN3: CJNE A,#057H,CJN0

MOV A,BL

MOV SETTYPE_FLAG,#01H

AJMP EXIT

CJN0: CJNE A,#046H,CJN1

AJMP OND

CJN1: CJNE A,#10H,CJN2

AJMP OFD

CJN2: CJNE A,#014H,DISPL ;menu flag ?

MOV SETTYPE_FLAG,#00H

;MENU FLAG//////////////////////////////////////////

INC INTSET_FLAG

MOV BL1,#01H

MOV A,INTSET_FLAG

CJNE A,#05H,DISPL

MOV INTSET_FLAG,#01H

;//////////////////////////////////////////////////

129

DISPL:

LJMP EXIT

;ON DCF 6

MINUTE/////////////////////////////////////////////

OND:

MOV C,P1.0

CLR P1.0

LCALL DELAY

MOV P1.0,C

MOV 43H,#00H

LJMP EXIT

;//////////////////////////////////////////////////

;OFF DCF 6 MINUTE//////////////////////////////////

OFD:

MOV C,P1.*

SETB P1.0

LCALL DELAY3

MOV P1.0,C

MOV 43H,#00H

;////////////////////////////////////////////////

;SET ADD OR JIAN/////////////////////////////////

EXIT: SETB EA

POP ACC

RETI

YS1: MOV R4,#20

GE1: MOV R5,#20

DJNZ R5,$

DJNZ R4,GE1 ;0.7ms delay RET

130

YS2: MOV R4,#10

GE2: MOV R5,#235

DJNZ R5,$

DJNZ R4,GE2 ;1ms delay

RET

YS3: MOV R4,#2

DE3: MOV R5,#248

DJNZ R5,$

DJNZ R4,DE3

RET

DELAY1:

MOV 50H,#12

DEL3: MOV 51H,#100

DEL2: MOV 52H,#197

DEL1: DJNZ 52H,DEL1

DJNZ 51H,DEL2

DJNZ 50H,DEL3

RET

DELAY2:

MOV 51H,#10

DEEL3: MOV 52H,#100

DEEL1:

DJNZ 52H,DEEL1

DJNZ 51H,DEEL3

RET

DELAY3:

MOV 54H,#150

DEEL6: MOV 55H,#100

131

DEEL5: MOV 56H,#197

DEEL4: DJNZ 56H,DEEL4

DJNZ 55H,DEEL5

DJNZ 54H,DEEL6

RET

DELAY4:

MOV 70H,#10

DKEL3: MOV 51H,#100

DKEL2: MOV 52H,#197

DKEL1: DJNZ 52H,DKEL1

DJNZ 51H,DKEL2

DJNZ 70H,DKEL3

RET

SETTAB:

DB 0FCH,60H,0DAH,0F2H,66H,0B6H,0BEH,0E0H,

0FEH,0F6H

DB 0EEH,3EH,9CH,7AH,9EH,8EH

END