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