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

📄 amy.asm

📁 电动按摩椅的原程序
💻 ASM
📖 第 1 页 / 共 4 页
字号:
;************************************************
;*2002.3.5 	motor-->kneading fuction prove 
;*		for model:588A---by john wu
;*2002.1.31  auto function prove---by john wu
;*2001.8.07---by john wu
;*2001.6.29---by john wu
;*auto/off-->on/off
;*self define-->auto
;************************************************
;************************************************
;*            program for 588                   *
;*                                              *
;*Author: lanaqiao                              *
;*        xiamenmengfaligongsi                  *
;*                                              *
;*Revision:1                                    *
;*Data:     2001.4.26                           *
;*Part:     pic16c57c                           *
;*Osc:     rc                                   *
;*Wdt:     on                                   *
;************************************************
;===static RAM register file definitions===
indf		equ 	0
rtcc		equ 	1
pc		equ 	2
status		equ 	3
fsr		equ 	4
porta		equ 	5
portb		equ 	6
portc		equ 	7

T500MS	equ	d'56'	;200*2.5ms=0.5s  (57,58...256--->200)


temp1		equ	8
temp2		equ	9
flag1		equ 	0a
;
;	bit0------>2ms maintimer,1 is available(maintimer)
;	bit1------>key delaytime,20ms,1 is available(key_time)
;	bit2------>(end_key_time)xingchengkaiguan qudou,100ms
;	bit3------>rounie huangxiangshijian,500ms(rhx_time)
;	bit4------>xingzuo huangxiangshijian,500ms(xhx_time)
;	bit5------>she bei qi dong (qd)
;	bit6------>15feng zhong ding shi(time_15)
;	bit7------>tong xin jie shu (finish)
flag2		equ	0b
;
;	bit0------>key down flag,1 is available(keydown)
;	bit1------>key processed flag,1 is available(key_processed)
;	bit2------>xingchengkaiguan daowei biaozhi,(end_position)
;	;bit3------>xingchengjishu,(xingcheng)
;	bit4------>(x_on)xingzuo yunxing zhuang tai
;	bit5------>zhidong,(auto)
;	bit6------>xiaotui on(xiaotui)
;	bit7------>datui on(datui)

flag3		equ	0c
;	bit0------>rounie zhengxiang huangxiang qingqiu(rzhx)
;	bit1------>rounie fanxiang huangxiang qingqiu(rfhx)
;	bit2------>xingzuo xiangshang huangxiang qingqiu(xshx)
;	bit3------>xingzuo xiangxia huangxiang qingqiu(xxhx)
;	bit4------>xingzuo shangxing(sx)
;	bit5------>xingzuo xia xing(xx)
;	bit6------>rou nie zheng zhuan(rz)
;	bit7------>rounie fan zhuan(rf)
flag4		equ	0d
;[	bit0------>qu1 biaozhi(z1) ]
;[	bit1------>qu2 biao zhi(z2)]
;[	bit2------>qu3 biao zhi(z3)]
;[	bit3------>quan shen(qs)   ];K5 K6 used
;	bit4------>qu1 xia xing jishu(z1_jis)
;	bit5------>xing cheng xia xing ji shu(xcjs_x)
;	bit6------>xing cheng shang xing ji shu(xcjs_s)
;	bit7------>zi ding yi,(self_de)
flag5		equ	0e
;	bit0------>kuan wei biao zhi(kuan)
;	bit1------>zhong wei biao zhi(zhong)
;	bit2------>zhai wei biao zhi(zhai)
;	bit3------>xia xian wei(xxw)
;	bit4------>shang xian wei (sxw)
;	bit5------>dao wei xiang ying(dwxy)
;	bit6------>beig
flag6		equ	0f
;	bit0------>zone 2 xia xing ji shu(z2_jis_x)
;	bit1------>zone 2 shang xing ji shu(z2_jis_s)
;	bit2------>zone 3 ji shu (z3_jis)
;	bit3------>zi ding yu qu jian shang xing ji shu(self_jis_s)
;	bit4------>zi ding yu qu jian xia xing ji shu(self_jis_x)

rhx_counter		equ	10
xhx_counter		equ	11
xc_counter1		equ	12	;wu
xc_counter2		equ	13	;wu
key_buffer		equ	14
tui_timer		equ 	15	;wu
a_timer			equ	16	;wu
t200ms			equ	17
mode			equ	18
counter_20ms		equ	19
qujian			equ	1a
send_num		equ 	1b
end_key_counter		equ	1c
ds_counter1		equ	1d
ds_counter2		equ	1e
flag7			equ	1f	;wu

z1_counter1		equ	30
z1_counter2		equ	31
self_define		equ	32
z2_counter1		equ	33
z2_counter2		equ	34
z3_counter1		equ	35
z3_counter2		equ	36
self_counter1	equ	37
self_counter2	equ	38

mode_ct		equ	39
beig_counter	equ	3a
jc_counter	equ	3b

;===flag and state bit definitions=======
c		equ 	0
dc		equ 	1
z		equ 	2


;;maintimer	equ	0
;;t200msb	equ	0
jc_timer	equ	0
key_time	equ	1
end_key_time	equ	2
rhx_time	equ	3
xhx_time	equ	4
qd		equ	5
time_15		equ	6
finish		equ	7

key_down	equ	0
key_processed	equ	1
end_position	equ	2
;xcjs		equ	3
z2_ds		equ	3
x_on		equ	4
auto		equ	5
xiaotui		equ	6
datui		equ	7

rzhx		equ	0
rfhx		equ 	1
xshx		equ	2
xxhx		equ	3
sx		equ	4
xx		equ	5
rz		equ	6
rf		equ	7

z1		equ	0
z2		equ	1
z3		equ	2
qs		equ	3
z1_jis		equ	4
xcjs_x		equ	5
xcjs_s		equ	6
self_de		equ	7

kuan		equ	0
zhong		equ	1
zhai		equ	2
xxw		equ	3
sxw		equ	4
dwxy		equ	5
beig		equ	6
z2_dx		equ	7

z2_jis_x	equ	0
z2_jis_s	equ	1
z3_jis		equ	2
self_jis_s	equ	3
self_jis_x	equ	4

;flag7
jcqq		equ	0
jcqq1		equ	1
a_timerb	equ	2
a_pause		equ	3	;auto pause position
a_jingbu	equ	4	;auto position
a_yaobu		equ	5	;auto position  
a_step		equ	6	;auto position
lcd_init	equ	7	;(wu)

spi_cs		equ 	0
spi_wr		equ 	2
spi_data	equ 	1

;======================================
	org 00
;======================================
;++++++timer programmer++++++++++++++++

timer2ms          ;2ms maintimer,flag1.0=1 is available
	movf 	rtcc,w
	movwf 	temp1
	movlw 	0f0h   ;1.25us*128*16=2.5ms
	subwf 	temp1,w
	btfsc 	status,c
	goto	timer2ms
	movlw 	0f0h
	movwf 	rtcc
	clrwdt
	retlw 	0

;--------------------------------------
timer
;;wu	btfss flag1,maintimer
;;	goto d_allok
;;	bcf flag1,maintimer
;;	clrf fsr

timer200ms
	decfsz	t200ms,f
	goto	key_delay
	movlw	d'80'
	movwf	t200ms

jcqq_timer
	btfss 	flag7,jcqq
	goto 	jcqq_t1
	movlw	jc_counter
	movwf	fsr
	decfsz 	indf,f
	goto 	auto_timer
;;	clrf	fsr
	bsf 	flag1,jc_timer
	goto	jcqq_t2
jcqq_t1	bcf	flag1,jc_timer
jcqq_t2	movlw	jc_counter
	movwf	fsr
	movlw	d'15'
	movwf	indf

auto_timer
	clrf	fsr
	btfss	flag7,a_pause
	goto	beiguang_delay
	decfsz	a_timer,f
	goto	beiguang_delay
	bsf	flag7,a_timerb	
	
beiguang_delay
	btfss 	flag5,beig
	goto 	timer_tui
	movlw	beig_counter
	movwf	fsr
	decfsz 	indf,f
	goto 	timer_tui
	clrf	fsr
	bcf 	flag5,beig

timer_tui
	clrf	fsr
	incf	tui_timer,f

time_15minutes
	btfss 	flag1,qd ;	she bei qi dong
	goto 	key_delay
	decfsz 	ds_counter1,f
	goto 	key_delay
	movlw 	0f9h
	movwf 	ds_counter1
	incf 	ds_counter2,f
	movlw 	d'36'		;wu 9
	subwf 	ds_counter2,w
	btfss 	status,z
	goto 	key_delay
	bsf 	flag1,time_15
	goto 	d_allok

key_delay           ;20ms
	btfss flag2,key_down  ;flag2.0=1 is available
	goto end_key_delay 
	btfsc flag2,key_processed
	goto end_key_delay
	decfsz counter_20ms,f
	goto end_key_delay
	movlw 0ah  ;wu 25ms  ;6*3.4ms=20ms
	movwf counter_20ms
	bsf flag1,key_time

end_key_delay      ;xing cheng kaiguan qu dou
	btfss flag2,end_position  ;flag2.1=1 is available
	goto rounie_hx_delay
	btfsc flag5,dwxy
	goto rounie_hx_delay
	decfsz end_key_counter,f
	goto rounie_hx_delay
	bsf flag1,end_key_time  ;flag1,2=1 is available
	movlw 0ah      ;10*3.4ms=34ms
	movwf end_key_counter

rounie_hx_delay
	btfsc flag3,rzhx   ;rounie zhengxiang huangxiang
	                   ;qing qiu biao zhi,1 you xiao,flag3.0
	goto rh1
	btfss flag3,rfhx   ;fangxiang huang xiang qingqiu,flag3.1
	goto xingzuo_hx_delay
	decfsz rhx_counter,f
	goto xingzuo_hx_delay
	bcf flag3,rfhx
	bsf flag3,rf  ;rou nie huang xiang shi jian 
		        ;biao zhi ,1 you xiao.flag1.3=1
	goto rh2

rh1	decfsz rhx_counter,f
	goto xingzuo_hx_delay
	bcf flag3,rzhx
	bsf flag3,rz
	btfss flag7,jcqq1
	goto rh2
	bcf flag7,jcqq1
	bsf flag7,jcqq
rh2
	movlw d'200'	;64h
	movwf rhx_counter

xingzuo_hx_delay
	clrf fsr
	btfss flag3,xshx ;xingzuo shangxiang huangxiang qing qiu
		     ;biao zhi ,flag3.2=1
	goto xh1
	decfsz xhx_counter,f
	goto xingchengjishu
	movlw d'200'	;32h
	movwf xhx_counter
	;bsf flag3,sx
	bcf flag3,xshx
	;clrf flag6
	;bcf flag4,z1_jis
	;bcf flag4,xcjs_s
	;bcf flag4,xcjs_x
	
	btfss flag4,z3
	goto nt1
	bsf flag3,sx
	bsf flag6,z3_jis
	movlw 35h
	movwf fsr
	movlw T500MS  ;150*3.4ms=0.5s
	movwf indf
	incf fsr,f
	;movlw 12h
	;movwf indf
	clrf indf
	clrf fsr
	goto xingchengjishu
nt1
	btfss flag4,qs
	goto nt2
	bsf flag3,sx
	btfss flag4,xcjs_x
	goto xingchengjishu
	bsf flag4,xcjs_s
	;bcf flag4,xcjs_x
	movlw T500MS;wu 6ah
	movwf xc_counter1
	clrf xc_counter2
	goto xingchengjishu
nt2
	btfss flag4,z2
	goto nt3
	;bsf flag4,xcji_s
	btfss flag5,z2_dx 
	goto nt21 ;bu shi z2 di xian huang xiang
	bsf flag3,sx
	bsf flag6,z2_jis_s
	;movlw 33h
	;movwf fsr
	;movlw 6ah
	;movwf indf
	;incf fsr,f
	;movlw 12h
	;clrf indf
	;clrf fsr
	goto xingchengjishu
nt21	    ;shang xing dao xian wei hou,ji shu
	bsf flag3,sx
	goto xingchengjishu
nt3
	;btfss flag4,self_de
	;goto nt4;
	;bsf flag3,sx
	;movlw 37h
	;movwf fsr
	;movlw 6ah
	;movwf indf
	;clrf fsr
	;movf xc_buffer2,w
	;movwf temp1
	;movlw 38h
	;movwf fsr
	;movf temp1,w
	;movwf indf
	;clrf fsr
	;goto xingchengjishu
;nt4
	btfss flag4,z1
	goto xingchengjishu
	bsf flag3,sx
	btfss flag4,z1_jis
	goto xingchengjishu
	movlw 30h
	movwf fsr
	movlw T500MS
	movwf indf
	incf fsr,f
	;movlw 12h
	clrf indf
	;clrf fsr
	goto xingchengjishu

xh1	btfss flag3,xxhx ;xingzuo xia huangxiang qingqiu,flag3.3=1
	goto xingchengjishu
	decfsz xhx_counter,f
	goto xingchengjishu
	movlw d'200'	;32h
	movwf xhx_counter ;xingzuo huang xiang shi jian ,flag1.4=1
	;bsf flag3,xx
	bcf flag3,xxhx
	;clrf flag6
	;bcf flag4,z1_jis
	;bcf flag4,xcjs_s
	;bcf flag4,xcjs_x

	btfss flag4,z1
	goto nt12
	bsf flag3,xx
	bsf flag4,z1_jis
	movlw 30h
	movwf fsr
	movlw T500MS
	movwf indf
	incf fsr,f
	clrf indf
	;clrf fsr
	goto xingchengjishu
nt12
	btfss flag4,z2
	goto nt13
	btfss flag2,z2_ds
	goto nt121;
	goto nt122
nt121
	bsf flag4,xcjs_x
	bsf flag3,xx
	movlw T500MS	;wu 6ah
	movwf xc_counter1
	clrf xc_counter2
	goto xingchengjishu
nt122	bsf flag3,xx
	bsf flag6,z2_jis_x
	movlw 33h
	movwf fsr
	movlw T500MS
	movwf indf
	incf fsr,f
	;movlw 12h
	clrf indf
	;clrf fsr
	goto xingchengjishu
nt13
	btfss flag4,qs
	goto nt14
	bsf flag3,xx
	bsf flag4,xcjs_x
	;bcf flag4,xcjs_s
	movlw T500MS	;wu 6ah
	movwf xc_counter1
	clrf xc_counter2
	goto xingchengjishu
nt14
	btfss flag4,z3
	goto xingchengjishu
	bsf flag3,xx
	btfss flag6,z3_jis
	goto xingchengjishu
	movlw 35h
	movwf fsr
	movlw T500MS
	movwf indf
	incf fsr,f
	clrf indf
	;clrf fsr
	;bsf flag6,z3_jis
	goto xingchengjishu

xingchengjishu
	clrf fsr              ;???,dai tiao shi
	btfsc	flag7,a_pause
	goto	d_allok		;wu
	btfss flag4,xcjs_x
	goto xingc_jis_s
	btfss flag3,xx
	goto xingc_jis_s
	incfsz xc_counter1,f
	goto zone1_delay
	movlw T500MS       ;wu 2.5ms*200;;(6ah)150*3.4ms=0.5s
	movwf xc_counter1
	incf xc_counter2,f  ;0.5s*x
	movlw 12h
	subwf xc_counter2,w
	btfss status,z
	goto zone1_delay
	btfss flag4,z2
	goto zone1_delay
	bsf flag6,z2_jis_x
	bcf flag4,xcjs_x
	bsf flag2,z2_ds
	movlw T500MS	;wu 6ah
	movwf xc_counter1
	clrf xc_counter2
	movlw 33h
	movwf fsr
	movlw T500MS
	movwf indf
	incf fsr,f
	clrf indf
	clrf fsr
	goto zone1_delay

xingc_jis_s
	btfss flag4,xcjs_s
	goto zone1_delay
	btfss flag3,sx
	goto zone1_delay
	incfsz xc_counter1,f
	goto zone1_delay
	movlw T500MS	;wu 6ah
	movwf xc_counter1
	incf xc_counter2,f
	;movlw 12h
	;subwf xc_counter2,w
	;btfss status,z
	;goto zone1_delay
	;bsf flag6,z2_jis_s
	;bcf flag4,xcjs_s
	;bsf flag5,z2_dx
	;movlw 6ah
	;movwf xc_counter1
	;clrf xc_counter2
	

zone1_delay                      ;???,dai tiao
	btfss flag4,z1
	goto zone2_delay
	btfss flag4,z1_jis
	goto zone2_delay
	btfss flag3,xx
	goto z11_j
	movlw 30h
	movwf fsr
	incfsz indf,f
	goto zone2_delay
	movlw T500MS    ;150*3.4ms=0.5s
	movwf indf
	incf fsr,f
	incf indf,f
	movlw 12h
	subwf indf,w
	btfss status,z
	goto zone2_delay
	clrf indf
	clrf fsr
	;bcf flag4,z1_jis
	bcf flag3,sx
	bcf flag3,xx
	bsf flag3,xshx
	goto zone2_delay
z11_j
	btfss flag3,sx
	goto zone2_delay
	movlw 30h
	movwf fsr
	incfsz indf,f
	goto zone2_delay
	movlw T500MS
	movwf indf
	incf fsr,f
	incf indf,f
	;clrf fsr
		 
zone2_delay
	clrf fsr
	btfss flag4,z2
	goto zone3_delay
	;btfss flag2,z2_ds
	;goto zone3_delay
	btfss flag6,z2_jis_x
	goto zone2_s
	movlw 33h
	movwf fsr
	incfsz indf,f
	goto zone3_delay
	movlw T500MS
	movwf indf
	incf fsr,f  ;34
	incf indf,f
	movlw 12h
	subwf indf,w
	btfss status,z
	goto zone3_delay
	clrf indf
	clrf fsr
	bcf flag6,z2_jis_x
	bsf flag5,z2_dx
	bcf flag3,xx
	bsf flag3,xshx
	goto zone3_delay
zone2_s
	btfss flag6,z2_jis_s
	goto zone3_delay
	movlw 33h
	movwf fsr
	incfsz indf,f
	goto zone3_delay
	movlw (T500MS-3)
	movwf indf
	incf fsr,f
	incf indf,f
	movlw 12h
	subwf indf,w
	btfss status,z
	goto zone3_delay
	clrf indf
	clrf fsr
	bcf flag6,z2_jis_s
	;bsf flag2,z2_ds
	bsf flag3,xxhx
	bcf flag3,sx
		

zone3_delay
	btfss flag4,z3
	goto d_allok;self_delay
	btfss flag6,z3_jis
	goto d_allok;self_delay
	btfss flag3,sx
	goto z3_j
	movlw 35h
	movwf fsr
	incfsz indf,f
	goto d_allok;self_delay
	movlw T500MS
	movwf indf
	incf fsr,f  ;f36
	incf indf,f
	movlw 12h
	subwf indf,w
	btfss status,z;decfsz indf,f
	goto zone3_delay
	;movlw 12h
	clrf indf
	clrf fsr
	bsf flag3,xxhx
	bcf flag3,xx
	bcf flag3,sx
	;bcf flag4,z3_jis
	goto d_allok
z3_j	
	btfss flag3,xx
	goto d_allok
	movlw 35h
	movwf fsr
	incfsz indf,f
	goto d_allok
	movlw T500MS
	movwf indf
	incf fsr,f
	incf indf,f
d_allok	clrf 	fsr	
	retlw 0
;------------------------------------
;=================init===============
init
	bsf	status,5
	bsf	status,6
	goto	initfw
;------------------------------------
start
	clrf 	fsr
	clrwdt
	movlw	0
	tris 	porta
	movlw	0f8h
	tris 	portb
	movlw	0f0h
	tris 	portc
	movlw 	6;	wu	7

⌨️ 快捷键说明

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