📄 wdt4minitialization.s43
字号:
//************************* Initialize All the system *************************//
#include "WDT4MDefination.h"
extern LCDALL
extern DLY100ms
extern LCDCLR
extern StopValve
PUBLIC INIT_ALL
PUBLIC INIT_TIMERA
extern SaveSystemData1
extern SaveSystemData2
RSEG CODE //PROM
//************************* Initialize All the system *************************//
INIT_ALL
CALL #INIT_WatchDog
CALL #INIT_SystemColck
CALL #INIT_P1
CALL #INIT_P2
CALL #INIT_P6
CALL #INIT_TIMERA
CALL #INIT_BasicTimer
CALL #INIT_RAM
CALL #INIT_END
CALL #RestoreUserData
RET
//**************************** Initialize Watchdog ***************************//
INIT_WatchDog
mov #WDTPW+WDTHOLD+WDTCNTCL+WDTSSEL,&WDTCTL
//mov #WDTPW+WDTHOLD+WDTCNTCL+WDTSSEL+WDTTMSEL,&WDTCTL ;Stop the Watchdog
bic.b #WDTIFG,&IFG1 ;Clear the watchdog INT flag
//bis.b #WDTIE,&IE1 ;Enable wdt timer interrupt
RET
//************************* Initialize SystemColck **************************//
INIT_SystemColck
mov.b #(128-1),&SCFQCTL ;MCLK = 32*ACLK,DCO+=0
mov.b #0,&SCFI0 ;FN_4 ;DCO center frequency is 1MHz
mov.b #XCAP18PF,&FLL_CTL0
mov.b #XT2OFF+SELM1+SELM0+SELS+FLL_DIV_8,&FLL_CTL1
RET
//***************************** Initialize Port 1 ***************************//
//*********************** P1.0 is used to count the flux **********************//
INIT_P1
clr.b &P1OUT ;Clear the outport rigister
clr.b &P1DIR ;all are input mode
//040817 bis.B #SenPWR,&P1DIR
//040817 bis.B #SenPWR,&P1OUT
clr.b &P1IES ;Low Voltage trig
clr.b &P1IFG ;Clear all the flag
mov.b #00H,&P1IE ;P1.0 interrupt is enabled
bis.B #TA0,&P1IE
RET
//***************************** Initialize port 2 ***************************//
//******** p2.0 is used to check card-input, p2.1 check water-stolen *********//
INIT_P2
clr.b &P2OUT ;Clear the outport rigister
clr.b &P2DIR ;all are input mode
clr.b &P2IE
clr.b &P2IES ;Low Voltage trig
bis.b #CardIn,&P2IES ;p2.0 is Low Voltage-triged but p2.1 high voltage-triged
clr.b &P2IFG ;Clear all the flag
mov.b #11111100B,&P5SEL ;COM and R- are selected
mov.b #CardIn+POAR,&P2IE ;P2.0 and p2.1 interrupt is enabled
RET
//***************************** Initialize Port 6 ***************************//
//*** RFrd is P6.0,RFwr is P6.1(IC card write),RFon(IC card read) is P6.2(power U2270B),
//*** RSDA is P6.3(EEROM data), SCL is P6.4(wake up 24C01), EEpow is P6.5(power EEROM),
//*** Mo_H is P6.6(motor control 1), Mo_L is P6.7(motor control 2)
INIT_P6
clr.b &P6OUT ;Clear the outport rigister
clr.b &P6DIR ;all are input mode
mov.b #EEpow+RFon+RFwr+Mo_L+Mo_H,&P6DIR ;p6.1,2,5,6,7 are output mode
bis.b #BIT0,&P6DIR
CALL #StopValve
RET
//***************************** Initialize TimerA ***************************//
INIT_TIMERA
mov #0000000100100000B,&TACTL ;CLOCK = SCLK, /8,
RET
//************************** Initialize Basic Timer **************************//
INIT_BasicTimer
;0010 0110 32768/256/64 = 1/2 s Interrupt Frequency
mov.b #BTDIV+BTFRFQ1+BTIP2+BTIP0,&BTCTL ;LCD frame frequency @4Mux: 1024Hz
clr.b &BTCNT1
clr.b &BTCNT2
RET
//***************************** Initialize RAM ******************************//
INIT_RAM
mov #200h,AX ;RAM初始化
ClearRam
clr 0(AX)
incd AX
cmp #02c0h,AX
jlo ClearRam
RET
//************************* Initialize END ***************************//
INIT_END
MOV.B #DSPTM_,&DSPTM
call #LCDALL ;显示88888.888
// BuzOn
// call #DLY100ms
// BuzOff
// call #DLY100ms
// BuzOn
// call #DLY100ms
// BuzOff
MOV #30H,AX
INITDelay
call #DLY100ms
DEC AX
JNZ INITDelay
RET
//************************* Restore UserData ***************************//
RestoreUserData
MOV #SystemDataFlashA,AX
RUDNXT0
MOV #SystemDataLength,CX
MOV #SystemDataRAM,DX
RUDNXT1
MOV.B 0(AX),0(DX)
CMP.B 0(AX),0(DX)
JNE RUDNXT1
INC AX
INC DX
DEC CX
JNZ RUDNXT1
cmp #0AAAAH,&DataOK
jeq RUDNXT2
cmp #SystemDataFlashA+100H,AX
jne RUDNXT0
BIS #DataWrongFG
RUDNXT2
cmp #SystemDataFlashA+100H,AX
jne RUDNXT5
call #SaveSystemData1
jmp RUDNXT6
RUDNXT5
cmp #0AAAAH,&10FEH
JEQ RUDNXT6
call #SaveSystemData2
RUDNXT6
BIC #NFG
CMP #75,&State ;置状态标志
JEQ RUDNXT3
BIS #NFG
RUDNXT3
//BIC #VALVEFG
//CMP #0AAAAH,&ValveState ;Valve state
//JEQ RUDNXT4
BIC #VALVEFG
bis #CloseValveFG
bic #CloseValve2FG
clr.b &VCCOUNT
clr.b &VCP1INT
RUDNXT4
mov.b #DSPTM_,&DSPTM
mov.b #0,&DSPNO ;disply remain
bis #DSPFG
RET
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -