⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mnapp.asm

📁 这是一个完整的除湿机方案!另包含SCH原理图。希望对用松翰单片机的朋友有帮助!
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;温度检测
tempretp:
	b0bts0	temphumiflag
	jmp	tempretp90
	b0bclr	fp00ien
	b0bclr	fp00irq
	mov	a,temchat
	b0bts1	fz
	jmp	tempretp90	
	b0mov     a,chkstat
	@jmp_a    7
	jmp	mnchkrx1
	jmp	mnchkrx2
	jmp	mnchkrx3
	jmp	mnchkrx4
	jmp	mnchkrx5


	
mnchkrx1:	
	call	discharge
	mov	a,#4
	mov	temchat,a		;//set the delay timer constant
	mov	a,#1
	mov	chkstat,a
	jmp	tempretp90
	
mnchkrx2:	
	call	rstandcharge
	mov	a,#1			;//set the delay timer constant
	mov	temchat,a
	mov	a,#2
	mov	chkstat,a
	jmp	tempretp90
	
mnchkrx3:
	call	discharge
	mov	a,#4			;//set the delay timer constant
	mov	temchat,a
	mov	a,#3
	mov	chkstat,a
	jmp	tempretp90
	
mnchkrx4:	
	call	rntccharge
	mov	a,#1			;//set the delay timer constant
	mov	temchat,a
	mov	a,#4
	mov	chkstat,a
	jmp	tempretp90

mnchkrx5:
	call	discharge
	mov	a,#4			;//set the delay timer constant
	mov	temchat,a	
	clr	chkstat

	@RST_WDT

	b0bts0	tempkipflag
	jmp	tempretp10
	b0bset	tempkipflag
	mov	a,tmrf1
	mov	tmrf11,a
	mov	a,tmrf2
	mov	tmrf12,a
	mov	a,tmrntc1
	mov	tmrntc11,a
	mov	a,tmrntc2
	mov	tmrntc12,a
	jmp	tempretp90
tempretp10:
	b0bclr	tempkipflag
	mov	a,tmrf11
	add	tmrf1,a
	mov	a,tmrf12
	adc	tmrf2,a
	b0bclr	fc
	rrcm	tmrf2
	rrcm	tmrf1
	mov	a,tmrntc11
	add	tmrntc1,a
	mov	a,tmrntc12
	adc	tmrntc2,a
	b0bclr	fc
	rrcm	tmrntc2
	rrcm	tmrntc1

	mov_	temp0,tmrf1
	mov_	temp1,tmrf2
	mov_	temp2,tmrntc1
	mov_	temp3,tmrntc2
	call	comparerx
;	mov_	data1,temp4
;	mov_	data2,temp5
	b0bset	temphumiflag
	b0bset	detctflag	
tempretp90:
	ret
	
;**********************************************
;Name	:discharge
;Function:
;Input  :
;Output	:
;Register Used:
;***********************************************
discharge:
	mov	a,p1
	and	a,#11111001b
	mov	p1,a
	mov	a,#11111110b	
	mov	p1m,a		
discharge90:
	ret

;**********************************************
;Name	:rfcharge
;Function:
;Input  :
;Output	:
;Register Used:
;***********************************************
rstandcharge:
	mov	a,p1
	or	a,#00000010b
	mov	p1,a
	mov	a,#11111010b		;p1.1 output 1
	mov	p1m,a
	clr	tmrf1
	clr	tmrf2
	
rstandcharge1:
	mov	a,#1
	add	tmrf1,a
	mov	a,#0
	adc	tmrf2,a
	b0bts0	fc
	jmp	rstandcharge89
	b0bts1	pttesch
	jmp	rstandcharge1
	
	jmp	rstandcharge90
rstandcharge89:
	mov	a,#0ffh			;//error  overflow
	mov	tmrf1,a
	mov	tmrf2,a	

rstandcharge90:
	ret

;**********************************************
;Name	:rocharge
;Function:
;Input  :
;Output	:
;Register Used:
;***********************************************
rntccharge:
	mov	a,p1
	or	a,#00000100b
	mov	p1,a
	mov	a,#11111100b		;p1.2 output 1
	mov	p1m,a
	clr	tmrntc1
	clr	tmrntc2
	
rntccharge1:
	mov	a,#1
	add	tmrntc1,a
	mov	a,#0
	adc	tmrntc2,a
	b0bts0	fc
	jmp	rntccharge89
	b0bts1	pttesch
	jmp	rntccharge1
	
	jmp	rntccharge90
rntccharge89:
	mov	a,#0ffh			;//error  overflow
	mov	tmrntc1,a
	mov	tmrntc1,a	

rntccharge90:
	
	ret

;**********************************************
;Name	:comparerx
;Function:temp5,4=temp3,2/temp1,0
;Input  :temp0,temp1,temp2,temp3
;Output	:temp4,temp5
;Register Used:
;***********************************************
comparerx:

	clr	Temp4
	clr	Temp5	
	mov_	Temp9,#9
DividLoop:
	nop
DividCont1:		;16位除16位,已经是从高位开始减
	mov_	r1,temp2
	mov_	r2,temp3
	mov	A,temp2
	sub	A,temp0
	mov	temp2,A
	mov	A,temp3
	sbc	A,temp1
	mov	temp3,A
	bts1	FC
	jmp	RestoreData

	add_	temp4,#1
	mov	A,#0
	adc	temp5,A
	
	jmp	DividLoop

RestoreData:
	decms	temp9	
	jmp	L_RSD1
	jmp	DividEnd

L_RSD1:
	bclr	FC
	rlc	r1
	mov	temp2,A
	rlc	r2
	mov	temp3,A
	bclr	FC
	rlcm	temp4
	rlcm	temp5
	jmp	DividLoop
	
DividEnd:
comparerx90:
	ret

;****************************************************
;查表得到温度值
;data1,data2
detector:
	clr	rcount
	mov	a,#RxTable$m
	mov	y,a
	mov	a,#RxTable$l
	mov	z,a
detector10:
	nop	
	movc
	mov	r0,a
	mov	a,r
	mov	r1,a

	mov	a,data1
	sub	a,r0
	mov	a,data2
	sbc	a,r1
	b0bts1	fc
	jmp	detector20
	mov	a,#0
	mov	rcount,a
	mov	a,#0
	mov	r2,a
	jmp	detector60
	
detector20:			; 得到整数部分
	incms	z
	jmp	detector30	
	incms	y
	nop
detector30:		
	movc
	mov	r4,a
	mov	a,data1
	sub	a,r4
	mov	a,data2
	sbc	a,r
	b0bts0	fc
	jmp	detector50
	mov	a,r4
	mov	r0,a
	mov	a,r
	mov	r1,a
	incms	rcount
	nop
	mov	a,rcount
	sub	a,#40
	b0bts1	fc
	jmp	detector20
	mov	a,#40
	mov	rcount,a
	mov	a,#0
	mov	r2,a
	jmp	detector60


detector50:			;得到小数部分
	mov	a,r0
	sub	a,r4
	mov	r2,a
	mov	a,r1
	sbc	a,r
	mov	r3,a

	mov	a,r0
	sub	a,data1
	mov	r0,a
	mov	a,r1
	sbc	a,data2
	mov	r1,a
	call	DIV_HEX2B
	mov	a,r6
	add	rcount,a
	mov	a,r5
	mov	r2,a

detector60:
	call	CHA_HEXD1BTOBCD
	mov	a,r2
	mov	temp_dis_d,a
	mov	a,rcount
	mov	r0,a
	call	CHA_HEX1BTOBCD
	mov	a,r2
	mov	temp_dis_i,a


	b0bts1	tempfirflag
	jmp	detector80
;	mov	a,temp_dis_iold
;	cmprs	a,temp_dis_i
;	jmp	detector65
;	jmp	detector75
;detector65:	
	mov	a,temp_dis_iold
	sub	a,temp_dis_i
	b0bts1	fc
	jmp	detector70
	sub	a,#1
	b0bts1	fc
	jmp	detector79
	jmp	detector75
detector70:
	mov	a,temp_dis_i
	sub	a,temp_dis_iold
	sub	a,#1
	b0bts1	fc
	jmp	detector79
detector75:
	mov	a,tempcount
	sub	a,#5
	b0bts0	fc
	jmp	detector79
	incms	tempcount
	nop	
	mov	a,temp_dis_iold
	mov	temp_dis_i,a
	mov	a,temp_dis_dold
	mov	temp_dis_d,a
	jmp	detector80
detector79:
	clr	tempcount
detector80:
	b0mov	y,#lcdwtable$m
	b0mov	z,#lcdwtable$l
	swap	temp_dis_i
	and	a,#0fh
	add	z,a
	movc
	mov	seg1,a
	mov	a,r
	mov	seg2,a
	b0mov	y,#lcdwtable$m
	b0mov	z,#lcdwtable$l
	mov	a,temp_dis_i
	and	a,#0fh
	add	z,a
	movc
	mov	seg3,a
	mov	a,r
	or	a,#00010000b
	mov	seg4,a
	b0mov	y,#lcdwtable$m
	b0mov	z,#lcdwtable$l
	mov	a,temp_dis_d
	and	a,#0fh
	add	z,a
	movc
	mov	seg5,a
	mov	a,r
	or	a,#00010000b
	mov	seg6,a

	mov	a,temp_dis_i
	mov	temp_dis_iold,a
	mov	a,temp_dis_d
	mov	temp_dis_dold,a
	b0bset	tempfirflag
	ret

;********************************************
;湿度检测
humidretp:
	b0bts1	temphumiflag
	jmp	humidretp90
	b0bts0	firsrecflag
	jmp	humidretp10
	b0bset	firsrecflag
	b0bts0	firsrecflag2
	jmp	humidretp5
	b0bset	firsrecflag2
	mov	a,#4
	mov	freqconut,a
humidretp5:
	b0bclr	t250msflag
	clr	timer250ms
	clr	timer10ms
	b0bclr	t10msflag
	clr	countfreql
	clr	countfreqh
;	clr	countfreql1
;	clr	countfreqh1
;	clr	countfreql2
;	clr	countfreqh2
;	clr	countfreql3
;	clr	countfreqh3
;	clr	countfreql4
;	clr	countfreqh4
	b0bclr	fp00irq
	b0bset	fp00ien
;	b0bclr	fp00irq

humidretp10:
	b0bts1	t250msflag
	jmp	humidretp90

	b0bclr	fp00ien
	b0bclr	fp00irq
	b0bclr	temphumiflag
	b0bclr	firsrecflag
	b0bts1	startdisflag
	jmp	humidretp25
	decms	freqconut
	jmp	humidretp12
	jmp	humidretp20
humidretp12:
	mov	a,#countfreql1$m
	mov	y,a
	mov	a,#countfreql1$l
	mov	z,a
	mov	a,freqconut
	mov	ww0,a
	b0bclr	fc
	rlc	ww0
	add	z,a
	mov	a,countfreql
	mov	@yz,a
	incms	z
	nop
	mov	a,countfreqh
	mov	@yz,a
;	b0bclr	t250msflag
;	clr	timer250ms
;	clr	countfreql
;	clr	countfreqh
;	b0bclr	fp00irq
;	b0bset	fp00ien
;	b0bclr	fp00irq
	jmp	humidretp90
humidretp20:
;	b0bclr	fp00ien
;	b0bclr	fc
;	rlcm	countfreql
;	rlcm	countfreqh
;	b0bclr	fc
;	rlcm	countfreql
;	rlcm	countfreqh
	mov	a,countfreql
	mov	countfreql1,a
	mov	a,countfreqh
	mov	countfreqh1,a
;	clr	countfreql
;	clr	countfreqh
;	mov	a,countfreql1
;	add	countfreql,a
;	mov	a,countfreqh1
;	adc	countfreqh,a

;	mov	a,countfreql2
;	add	countfreql,a
;	mov	a,countfreqh2
;	adc	countfreqh,a

;	mov	a,countfreql3
;	add	countfreql,a
;	mov	a,countfreqh3
;	adc	countfreqh,a

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -