LIST P=PIC16C57
W EQU 0
C EQU 0
STATUS EQU 3
FSR EQU 4
RTCC EQU 1
F EQU 1
PC EQU 2
PA0 EQU 5
PA1 EQU 6
RA EQU 5
RB EQU 6
RC EQU 7
#DEFINE SCL RA,0
#DEFINE SDA RA,1
#DEFINE FOUT RA,2
#DEFINE JINT RB,0
#DEFINE ACF RB,1
#DEFINE SCR_OUT RB,2
#DEFINE WLED RB,3
#DEFINE LD1 RB,4
#DEFINE LD2 RB,5
#DEFINE LD3 RB,6
#DEFINE LD4 RB,7
cblock 10h ;體0->定義定時器
GE
SHI
BAI
QIAN
T1
T2
T_HUAN
T_H_BYTE
T_L_BYTE
T_TEMP1
T_TEMP2
T_1S
endc
cblock 30h ;體1->定義可控硅調壓
SCR_TEMP
SCR_HUAN
SCR_T1
SCR_T2
SCR_LED_TEMP
endc
cblock 50h ;體2
endc
ORG 7FFH
GOTO START
ORG 00H
START: MOVLW 00H ;\
TRIS RA ; \
MOVLW B'00000011' ; \
TRIS RB ; /端口狀態設定
MOVLW 00H ; /
TRIS RC ;/
CLRF RA
CLRF RB
CLRF RC
BSF STATUS,PA0 ;\
BCF STATUS,PA1 ; -進入主程序
GOTO SCR ;/
;============================時間定時存放頁3
ORG 600H
TIME: ;定時器寄存器清零
BCF FSR,5
BCF FSR,6
CLRF GE
CLRF SHI
CLRF BAI
CLRF QIAN
CLRF T_HUAN
CLRF T_H_BYTE
CLRF T_L_BYTE
CLRF T_TEMP1
CLRF T_TEMP2
CLRF T_1S
;關閉功率顯示
BCF WLED
;1 設RTCC為定時模式
MOVLW 7H
OPTION
;
;2 顯示-ON-
XIAN_ON1:
BCF STATUS,PA1
BCF STATUS,PA0
CALL XIAN_ON
BSF STATUS,PA0
BSF STATUS,PA1
;
;3 所有鍵松開?
MOVLW 0FFH
MOVWF RC
BTFSC JINT
GOTO XIAN_ON1
;
;4 顯示-ON-
XIAN_ON2:
;;;;;;;;;
BSF STATUS,PA0
BCF STATUS,PA1
CALL SCR
BSF STATUS,PA0
BSF STATUS,PA1
;;;;;;;;;
BCF STATUS,PA1
BCF STATUS,PA0
CALL XIAN_ON
BSF STATUS,PA1
BSF STATUS,PA0
;
;5 啟動/暫停鍵下?
MOVLW B'00000001'
MOVWF RC
BTFSS JINT
GOTO XIAN_ON2
;
;6 顯示-OF-
XIAN_OF1:
BCF STATUS,PA1
BCF STATUS,PA0
CALL XIAN_OF
BSF STATUS,PA1
BSF STATUS,PA0
;
;7 按鍵全松開?
MOVLW 0FFH
MOVWF RC
BTFSC JINT
GOTO XIAN_OF1
;8 分鐘寄存器為0?
FEN_ZERO:
MOVF T_H_BYTE,W
SKPZ
GOTO DANG_26
;
;8A秒鐘寄存器=0?
MOVF T_L_BYTE,W
SKPZ
GOTO DANG_26
;
;9 為0,顯示-OF-
BCF STATUS,PA1
BCF STATUS,PA0
CALL XIAN_OF
BSF STATUS,PA1
BSF STATUS,PA0
GOTO Q2
;
;26 不為0,顯示當前設定時間
DANG_26:
;對導通角寄存器加1
MOVLW .80
SUBWF SCR_TEMP,W
SKPNC
GOTO UF
INCF SCR_TEMP
;
;檢測到過零點?
UF: MOVF SCR_LED_TEMP,W
MOVWF RC
BTFSS ACF
GOTO UF
;
;按寄存器數據延時(控制導通角)
MOVLW 24H
MOVWF SCR_T1
MOVF SCR_TEMP,W
MOVWF SCR_T2
DECFSZ SCR_T2
GOTO $-1
DECFSZ SCR_T1
GOTO $-5
;
;觸發可控硅
BSF SCR_OUT
NOP
NOP
NOP
NOP
NOP
BCF SCR_OUT
;
;子程序返回
GOTO DANG_00
;
END