專注差異化嵌入式產(chǎn)品解決方案 給智能產(chǎn)品定制注入靈魂給予生命
提供開發(fā)工具、應(yīng)用測(cè)試 完善的開發(fā)代碼案例庫分享
從全面的產(chǎn)品導(dǎo)入到強(qiáng)大技術(shù)支援服務(wù) 全程貼心伴隨服務(wù),創(chuàng)造無限潛能!
提供新的芯片及解決方案,提升客戶產(chǎn)品競(jìng)爭(zhēng)力
提供最新的單片機(jī)資訊,行業(yè)消息以及公司新聞動(dòng)態(tài)
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->定義定時(shí)器
GE
SHI
BAI
QIAN
T1
T2
T_HUAN
T_H_BYTE
T_L_BYTE
T_TEMP1
T_TEMP2
T_1S
endc
cblock 30h ;體1->定義可控硅調(diào)壓
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 ; /端口狀態(tài)設(shè)定
MOVLW 00H ; /
TRIS RC ;/
CLRF RA
CLRF RB
CLRF RC
BSF STATUS,PA0 ;\
BCF STATUS,PA1 ; -進(jìn)入主程序
GOTO SCR ;/
;============================時(shí)間定時(shí)存放頁3
ORG 600H
TIME: ;定時(shí)器寄存器清零
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
;關(guān)閉功率顯示
BCF WLED
;1 設(shè)RTCC為定時(shí)模式
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 啟動(dòng)/暫停鍵下?
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,顯示當(dāng)前設(shè)定時(shí)間
DANG_26:
;對(duì)導(dǎo)通角寄存器加1
MOVLW .80
SUBWF SCR_TEMP,W
SKPNC
GOTO UF
INCF SCR_TEMP
;
;檢測(cè)到過零點(diǎn)?
UF: MOVF SCR_LED_TEMP,W
MOVWF RC
BTFSS ACF
GOTO UF
;
;按寄存器數(shù)據(jù)延時(shí)(控制導(dǎo)通角)
MOVLW 24H
MOVWF SCR_T1
MOVF SCR_TEMP,W
MOVWF SCR_T2
DECFSZ SCR_T2
GOTO $-1
DECFSZ SCR_T1
GOTO $-5
;
;觸發(fā)可控硅
BSF SCR_OUT
NOP
NOP
NOP
NOP
NOP
BCF SCR_OUT
;
;子程序返回
GOTO DANG_00
;
END