|
;----------------------------------------------------------------------------- ; Assembly main line ;-----------------------------------------------------------------------------
include "m8c.inc" ; part specific constants and macros include "memory.inc" ; Constants & macros for SMM/LMM and Compiler include "PSoCAPI.inc" ; PSoC API definitions for all User Modules
export _main export drive export gpio_isr export checkhall export initial export delay export timer_isr export startpwm export pumpcurrent export caijicurrent export checkzhuanba export pumppower export caijipower export xiefang export delay2 export oprun export startdrive export xianshi
area bss(RAM) power: blk 1 hall_35: blk 1 hall_34: blk 1 temphall_35: blk 1 flag_gpio: blk 1 flag_zb: blk 1 flag_oprun: blk 1 ;flag_pumpzb: blk 1 flagp15: blk 1 flagbuchang: blk 1 ;flag_zhuli: blk 1 flag_8sds: blk 1 ;flagzl: blk 1 ;flag_zbyan: blk 1 flag_dz: blk 1 flag_gdz: blk 1 flag_run: blk 1 flag_zbon: blk 1 flag_zbyan: blk 1 flag_zhuli: blk 1 flag_power: blk 1 flag_low: blk 1 flag_ckzb: blk 1 flag_xianshi: blk 1 flag_xianshizl: blk 1 flag_dl1: blk 1 flag_dl2: blk 1 flag_dl3: blk 1 flag_dl4: blk 1 temphall: blk 1 temp1: blk 1 temp2: blk 1 temp3: blk 1 temp4: blk 1 temp5: blk 1 temp6: blk 1 temp7: blk 1 temp8: blk 1 temp9: blk 1 temp10: blk 1 temp11: blk 1 temp16: blk 1 temp17: blk 1 temp18: blk 1 temp19: blk 1 temp20: blk 1 temp21: blk 1 temp22: blk 1 temp30: blk 1 temp31: blk 1 temp32: blk 1 temp40: blk 1 temp51: blk 1 temp1000: blk 1 temp61: blk 1 temp62: blk 1 temp63: blk 1 temp64: blk 1 temp65: blk 1 count32: blk 1 count512: blk 1 count256: blk 1 value_6E: blk 1 tempduty_30: blk 1 duty_30: blk 1 duty_2F: blk 1 current: blk 1 tempcurrent: blk 1 value_4B: blk 1 current_48: blk 1 zl0: blk 1 zl1: blk 1 zl74: blk 1 zl77: blk 1 area text(ROM) _main:
call initial
mainloop: M8C_EnableGInt cmp [flag_gdz],1 jz daiyuduty9 cmp [duty_30],60 jnc daiyuduty1 mov [current_48],164 jmp daiyuduty8 daiyuduty1: cmp [duty_30],70 jnc daiyuduty2 mov [current_48],162 jmp daiyuduty8 daiyuduty2: cmp [duty_30],80 jnc daiyuduty3 mov [current_48],160 jmp daiyuduty8 daiyuduty3: cmp [duty_30],90 jnc daiyuduty4 mov [current_48],159 jmp daiyuduty8 daiyuduty4: cmp [duty_30],100 jnc daiyuduty5 mov [current_48],157 jmp daiyuduty8 daiyuduty5: cmp [duty_30],110 jnc daiyuduty6 mov [current_48],154 jmp daiyuduty8 daiyuduty6: cmp [duty_30],130 jnc daiyuduty7 mov [current_48],152 jmp daiyuduty8 daiyuduty7: mov [current_48],152 jmp daiyuduty8
daiyuduty9: mov [current_48],147 daiyuduty8: call caijicurrent call startpwm
cmp [flag_zb],1 jnz mainloop1 call caijizhuanba ;call checkzhuanba call pumppower and [flag_zb],00H jmp mainloop mainloop1: cmp [flag_power],1 jnz mainloop2 call caijipower call pumpzhuanba and [flag_power],00H jmp mainloop mainloop2: cmp [flag_ckzb],1 jnz mainloop call checkzhuanba call xianshi and [flag_ckzb],00H jmp mainloop ;///////////////////// ;/// ;////////////////////// timer_isr: push A push X inc [temp1000] M8C_EnableGInt or reg[INT_MSK0],20H inc [count256] jnc timer_p1 mov [flag_zb],1 jmp timer_p11 ;------------------- timer_p1: cmp [count256],128 jnz timer_p10 mov [flag_power],1 jmp timer_p11 timer_p10: cmp [count256],200 jnz timer_p11 mov [flag_ckzb],1 timer_p11: ;----------------- jmp daz2 ;daozhuan tst reg[PRT0DR],04H jnz daz1 cmp [flag_oprun],1 jz daz3 cmp [flag_zbon],1 jz daz2 cmp [flag_run],1 jz daz2 and [temp22],00H inc [temp21] jnc daz2 daz3: mov [flag_oprun],1 jmp daz2 daz1: cmp [flag_oprun],0 jz daz4 cmp [flag_zbon],1 jz daz2 cmp [flag_run],1 jz daz2 and [temp21],00H inc [temp22] jnc daz2 daz4: and [flag_oprun],00H daz2:
;---------------- ;-------------------------------- ;zhuli cmp [flag_oprun],1 jnz gozhuli and [zl77],00H and [zl74],00H jmp timer_huanxiang gozhuli: ;cmp [flag_8sds],1 ;jz timer_huanxiang and [temp17],00H and [temp16],00H inc [count32] cmp [count32],17H ;0A jnz timer_huanxiang and [count32],00H timer_p6: tst reg[PRT0DR],80H jz timer_ce0 timer_p4: inc [temp16] cmp [temp16],3 jnz timer_p6 and [temp16],00H
cmp [flag_zhuli],1 jz timer_cf1 mov [flag_zhuli],1 inc [temp18] cmp [temp18],2 jnz timer_d1 mov [temp18],1 mov A,[zl0] cmp A,[zl1] jnc timer_d0 ;------------- ;cmp [zl0],15 ;jnc timer_d0 ;--------------- mov A,20 ;178 sub A,[zl1] jnc timer_d0 ;178>[zl1] jmp ;jc timer_d0 mov [zl1],A ;inc [zl75] ;mov A,[zl75] ;sub A,2 ;jnc timer_d1 ;mov [zl75],2 mov A,[zl1] add [zl74],A rrc [zl74] timer_d1: and [zl1],00H timer_cf1: inc [zl1] ;----------------- cmp [zl1],120 jz timer_d2_1 jmp timer_d3 timer_d2_1: and [zl1],00H jmp timer_d2 ;--------------- jz timer_d2 jmp timer_d3 timer_ce0: inc [temp17] cmp [temp17],3 jnz timer_p6 and [temp17],00H
cmp [flag_zhuli],1 jnz timer_ce0_p1 and [zl0],00H and [flag_zhuli],00H timer_ce0_p1: inc [zl0] ;--------------- cmp [zl0],120 jz timer_d2_2 jmp timer_d3 timer_d2_2: and [zl0],00H jmp timer_d2 ;----------------- jz timer_d2 jmp timer_d3
timer_d0: and [zl1],00H timer_d2: and [temp18],00H ;and [zl75],00H cmp [zl74],0 jz timer_d3 ;dec [zl74] sub [zl74],50 jnc timer_d3 and [zl74],00H timer_d3: mov A,[zl77] cmp A,[zl74] jz timer_huanxiang mov A,[zl77] cmp A,[zl74] jnc timer77dec inc [zl77] ;add [zl77],1 jnc timer_huanxiang dec [zl77] jmp timer_huanxiang timer77dec: sub [zl77],2 jnc timer_huanxiang and [zl77],00H timer_huanxiang: ;---------------------------------- ;-------------------- ;dingsu cmp [flag_oprun],1 jnz godingsu and [flag_8sds],00H and [count512],00H jmp timer_p7 godingsu:
cmp [flag_8sds],1 jz timer_p7 cmp [flag_zbon],1 jnz timer_p7 cmp [count256],0 jnz timer_p7
;mov A,[duty_2F] mov A,[duty_30] sub A,[temp6] jnc timer_p8 add A,3 jc timer_p9 jishu: inc [count512] cmp [count512],253 jc timer_p7 and [count512],00H
mov [flag_8sds],1 jmp timer_p9 timer_p8: sub A,3 jnc timer_p9 jmp jishu ;mov [flag_8sds],1 timer_p9: and [count512],00H ;mov A,[duty_2F] mov A,[duty_30] mov [temp6],A timer_p7:
;---------------------- ;shache ;------------- tst reg[PRT1DR],20H jz timer_p3 mov [flagp15],1 and [duty_2F],00H and [duty_30],00H and [zl77],00H and [zl74],00H and [flag_8sds],00H timer_p3: ;----------------- exit: ;-------------------- ;duzhuan ;jmp duzhuan2 cmp [flag_dz],1 jz duzhuan2 cmp [current],140 jc duzhuan1 cmp [flag_run],1 jz duzhuan1 cmp [count256],0 jnz duzhuan2 inc [temp20] mov [flag_gdz],1 cmp [temp20],45 jc duzhuan2 and [temp20],00H mov [flag_dz],1 jmp duzhuan2 duzhuan1: and [temp20],00H and [flag_dz],00H duzhuan2: ;--------------------- ;duzhuan cmp [flag_dz],1 jz gpio3 mov A,[hall_35] cmp A,[temphall] jnz gpio1 inc [temp19] cmp [temp19],4 jc gpio2 and [temp19],00H and [flag_run],00H jmp gpio2 gpio1: and [temp19],00H mov [flag_run],1 and [flag_gdz],00H gpio2: mov A,[hall_35] mov [temphall],A gpio3: ;------------------------
mov reg[INT_MSK0],00H cmp [flag_run],1 jz gpio5 cmp [flag_dz],1 jz gpio5 cmp [flag_zbon],1 jz gpio4 cmp [zl77],0 jnz gpio4 call xiefang jmp gpio5 gpio4: cmp [duty_30],30 jnc gpio5 mov A,[duty_30] cpl A jz gpio5 cmp [flag_8sds],1 jz gpio5 call startdrive gpio5: pop A pop X reti ;/////////////////////// ;////// ;/////////////////////// gpio_isr: push A push X mov [flag_gpio],1 call checkhall call drive ;///////////////// ;xu yao qing diao gan rao de hall xinhao yinqi de zhongduan ;mov reg[INT_VC], 0 ; Clear all pending interrupts mov reg[INT_MSK3],0 mov reg[INT_CLR0],0
;////////////////////////// pop A pop X reti ;////////////////// ;/// ;///////////// startdrive: ;cmp [flag_oprun],1 ;jnz startfirst_p5 ;call oprun ;ret startfirst_p5:
tst [hall_35],FEH ;HALL =1 jz startmovround_p13_3 tst [hall_35],FDH ;HALL =2 jz startmovround_p17_6 tst [hall_35],FCH ;HALL =3 jz startmovround_p17_2 tst [hall_35],FBH ;HALL =4 jz startmovround_p27_5 tst [hall_35],FAH ;HALL =5 jz startmovround_p13_1 tst [hall_35],F9H ;HALL =6 jz startmovround_p27_4 ret
startmovround_p13_3: mov reg[PRT2GS],80H mov reg[PRT1GS],00H ;//////////////// mov reg[PRT1DR],04H ;p1.0=0;p1.1=0;p1.2=1;p1.3=0...[p1.6=0];p1.7=0 mov reg[PRT2DR],41H ;p2.0=1;...;p2.6=1;[p2.7=1] mov [hall_34],3 ret startmovround_p17_6: mov reg[PRT2GS],00H mov reg[PRT1GS],08H ;///////////////// mov reg[PRT1DR],44H ;;p1.0=0;p1.1=0;p1.2=1;[p1.3=1]...p1.6=1;p1.7=0 mov reg[PRT2DR],02H ;;p2.0=;...;[p2.6=0];p2.7=0 mov [hall_34],6 ret startmovround_p17_2: mov reg[PRT2GS],00H mov reg[PRT1GS],08H ;////////////////// mov reg[PRT1DR],04H ;;p1.0=0;p1.1=0;p1.2=1;[p1.3=1]...[p1.6=0];p1.7=0 mov reg[PRT2DR],43H ;;;p2.0=;...;p2.6=1;p2.7=0 mov [hall_34],2 ret startmovround_p27_5: mov reg[PRT1GS],80H mov reg[PRT2GS],00H ;/////////////// mov reg[PRT1DR],40H ;;p1.0=0;p1.1=0;[p1.2=0];p1.3=0...p1.6=1;[p1.7=1] mov reg[PRT2DR],44H ;;p2.0=;...;p2.6=1;p2.7=00 mov [hall_34],5 ret startmovround_p13_1: mov reg[PRT2GS],80H mov reg[PRT1GS],00H ;///////////////// mov reg[PRT1DR],40H ;;p1.0=0;p1.1=0;[p1.2=0];p1.3=0...p1.6=1;p1.7=0 mov reg[PRT2DR],45H ;;p2.0=;...;p2.6=1;[p2.7=1] mov [hall_34],1 ret startmovround_p27_4: mov reg[PRT1GS],80H mov reg[PRT2GS],00H ;//////////////// mov reg[PRT1DR],44H ;;p1.0=0;p1.1=0;p1.2=1;p1.3=0...p1.6=1;[p1.7=1] mov reg[PRT2DR],06H ;;p2.0=;...;[p2.6=0];p2.7= mov [hall_34],4 ;----------------- ret ;////////////////////// ;//// ;////////////////////// startpwm: cmp [flag_low],0 jz startpwm_p6
cmp [flagp15],1 jz startpwm_p6
cmp [flag_dz],1 jz startpwm_p6
mov A,[current_48] sub A,[current] mov [value_4B],A jnc startpwm_p7 add A,6 ;//4 jnc startpwm_p8 add A,6 jc startpwm_p9 jmp startpwm_p8 startpwm_p7: mov A,[duty_2F] cmp A,[duty_30] jnz startpwm_p1 ;be not equal to mov A,[duty_2F] mov [duty_30],A jmp startpwm_p4 startpwm_p1: mov A,[duty_2F] cmp A,[duty_30] jnc startpwm_p2 ;[duty_2F]>[duty_30] duty_30++ jmp startpwm_p3 startpwm_p2: mov A,[value_4B] cmp A,10 ;//20 jnc startpwm_p10 inc [temp4] cmp [temp4],3 jnc startpwm_p10 jmp startpwm_p4 startpwm_p10: and [temp4],00H inc [duty_30] ;--------------- cmp [flag_oprun],1 jnz startpwm_p4 cmp [duty_30],150 jc startpwm_p4 mov A,[duty_30] sub A,150 jc startpwm_p4 sub [duty_30],A
;-------------- jmp startpwm_p4 startpwm_p3: mov A, 04H jmp startpwm_p5 startpwm_p8: mov A, 01H jmp startpwm_p5 startpwm_p9: mov A, 02H jmp startpwm_p5 startpwm_p6: mov A,20 jmp startpwm_p5 startpwm_p5: sub [duty_30],A jnc startpwm_p4 and [duty_30],00H startpwm_p4: mov A,[duty_30] ; call PWMDB8_1_WritePulseWidth call PWMDB8_1_DisableInt ; call PWMDB8_1_Start ret ;////////////////// ;/// ;//////////////////// caijicurrent: ;mov [temp5],3 M8C_EnableGInt caijicurrent_p1: call DELSIG8_1_fIsDataAvailable cmp A, 0 jz caijicurrent_p1 call DELSIG8_1_cGetDataClearFlag ;dec [temp5] ;jnz caijicurrent_p1 add A,128 add A, [current] rrc A mov [current],A ret ;//////////////////// ;///// ;////////////////////// pumpcurrent: M8C_EnableGInt ;mov A, PGA_2_G1_00 ;call PGA_1_SetGain mov A, PGA_2_HIGHPOWER call PGA_2_Start mov A,DELSIG8_1_HIGHPOWER call DELSIG8_1_Start call DELSIG8_1_StartAD ret ;/////////////////// ;////
|