專注差異化嵌入式產(chǎn)品解決方案 給智能產(chǎn)品定制注入靈魂給予生命
提供開發(fā)工具、應(yīng)用測(cè)試 完善的開發(fā)代碼案例庫(kù)分享
從全面的產(chǎn)品導(dǎo)入到強(qiáng)大技術(shù)支援服務(wù) 全程貼心伴隨服務(wù),創(chuàng)造無(wú)限潛能!
提供新的芯片及解決方案,提升客戶產(chǎn)品競(jìng)爭(zhēng)力
提供最新的單片機(jī)資訊,行業(yè)消息以及公司新聞動(dòng)態(tài)
;================================= ;4位LED數(shù)碼管閃爍控制程序,3鍵控制《SET》、《+》、《-》 ;write by:華宇電子(HUAYU)2005/05/20 ;====================================================== LIST P=16F873 INCLUDE "P16F873.INC" DL_CUT EQU 20H DL_CUT1 EQU 21H DISP_CUT EQU 22H FLASH_CON EQU 23H K_FLAG EQU 24H DS1 EQU 25H DS2 EQU 26H DS3 EQU 27H DS4 EQU 28H SEC EQU 29H SHOW EQU 2AH PP EQU 2BH
ORG 00H GOTO START ORG 10H START NOP MOVLW 0FFH MOVWF PP MOVLW 10H MOVWF FLASH_CON MOVLW 00H MOVWF K_FLAG MOVLW 01H MOVWF DS1 MOVLW 05H MOVWF DS2 MOVLW 00H MOVWF DS3 MOVLW 08H MOVWF DS4 CLRF SEC MAIN CLRF PORTC CLRF PORTB BANKSEL TRISA MOVLW 00H MOVWF TRISA MOVWF TRISB MOVWF TRISC BANKSEL PORTA
CALL DISPLAY CALL KEYSCAN DECFSZ PP GOTO $-1 DECFSZ DISP_CUT GOTO MAIN MOVLW 03FH MOVWF DISP_CUT COMF SEC GOTO MAIN ;============== DISPLAY CLRF SHOW MOVF DS1,W CALL TAB MOVWF PORTC BTFSS FLASH_CON,0 GOTO DISP1 MOVF SEC,W ANDWF FLASH_CON,W MOVWF SHOW DISP1 MOVLW B'11111110' ADDWF SHOW,W MOVWF PORTB CALL DELAY CLRF SHOW MOVF DS2,W CALL TAB MOVWF PORTC BTFSS FLASH_CON,1 GOTO DISP2 MOVF SEC,W ANDWF FLASH_CON,W MOVWF SHOW DISP2 MOVLW B'11111101' ADDWF SHOW,W MOVWF PORTB CALL DELAY CLRF SHOW MOVF DS3,W CALL TAB MOVWF PORTC BTFSS FLASH_CON,2 GOTO DISP3 MOVF SEC,W ANDWF FLASH_CON,W MOVWF SHOW DISP3 MOVLW B'11111011' ADDWF SHOW,W MOVWF PORTB CALL DELAY CLRF SHOW MOVF DS4,W CALL TAB MOVWF PORTC BTFSS FLASH_CON,3 GOTO DISP4 MOVF SEC,W ANDWF FLASH_CON,W MOVWF SHOW DISP4 MOVLW B'11110111' ADDWF SHOW,W MOVWF PORTB CALL DELAY CLRF SHOW
RETURN ;================== TAB ADDWF PCL,1 RETLW 3FH RETLW 06H RETLW 5BH RETLW 4FH RETLW 66H RETLW 6DH RETLW 7DH RETLW 07H RETLW 7FH RETLW 6FH ;B'01101111' ;========================== DELAY MOVLW 05H MOVWF DL_CUT DELAY2 MOVLW 0FH MOVWF DL_CUT1 DELAY1 DECFSZ DL_CUT1 GOTO DELAY1 DECFSZ DL_CUT GOTO DELAY2 RETURN ;======================== KEYSCAN BANKSEL TRISB MOVLW 0FFH MOVWF TRISB BANKSEL PORTB BTFSS PORTB,0 GOTO KEY1 BTFSS PORTB,1 GOTO KEY2 BTFSC K_FLAG,0 GOTO DOKEY1 BTFSC K_FLAG,1 GOTO DOKEY2 RETURN KEY1 CALL DELAY BTFSS PORTB,0 BSF K_FLAG,0 RETURN KEY2 CALL DELAY BTFSS PORTB,1 BSF K_FLAG,1 RETURN
DOKEY1 BCF K_FLAG,0 RRF FLASH_CON BTFSS STATUS,C RETURN BCF STATUS,C MOVLW 10H MOVWF FLASH_CON RETURN DOKEY2 BCF K_FLAG,1 BTFSC FLASH_CON,0 INCF DS1 BTFSC FLASH_CON,1 INCF DS2 BTFSC FLASH_CON,2 INCF DS3 BTFSC FLASH_CON,3 INCF DS4 RETURN ;================ END