專(zhuān)注差異化嵌入式產(chǎn)品解決方案 給智能產(chǎn)品定制注入靈魂給予生命
提供開(kāi)發(fā)工具、應(yīng)用測(cè)試 完善的開(kāi)發(fā)代碼案例庫(kù)分享
從全面的產(chǎn)品導(dǎo)入到強(qiáng)大技術(shù)支援服務(wù) 全程貼心伴隨服務(wù),創(chuàng)造無(wú)限潛能!
提供新的芯片及解決方案,提升客戶(hù)產(chǎn)品競(jìng)爭(zhēng)力
提供最新的單片機(jī)資訊,行業(yè)消息以及公司新聞動(dòng)態(tài)
;========================================================== ;= use buffer : Address => EEPROM action address buffer ;= example: movlw D'10' 位址10讀出 ;= call EE_READ_A ;= : Address = D'10' ;= : TMP1,TMP2 = data ;=========================================================== ; EE_READ_A: MOVWF ADDRESS EE_READ: MOVLW D'02' MOVWF CNT1 BCF STATUS,C RLF ADDRESS,W BANK_1 MOVWF EEADR ;point to EEPROM EE_READ_LOOP: BANK_1 BSF EECON1,RD ;read data from EEP MOVFW EEDATA ; INCF EEADR,F BANK_0 BTFSC CNT1,1 MOVWF TMP2 BTFSS CNT1,1 MOVWF TMP1 DECFSZ CNT1,F GOTO EE_READ_LOOP RETURN
;================================================================ ;= use buffer : Address => EEPROM action address buffer ;= example: movlw H'55' 位址10寫(xiě)入0x55 0x55 ;= movwf TMP1 ;= movwf TMP2 ;= movlw D'10' ;= call EE_WRITE_A ;= Address = D'12' ;================================================================ ; MEMORY_WRITE: MOVWF TMP1 CLRF TMP2 MOVLW PWR_MEM EE_WRITE_A: MOVWF ADDRESS EE_WRITE: MOVLW D'02' MOVWF CNT1 BCF STATUS,C RLF ADDRESS,W BANK_1 MOVWF EEADR ;point to EEPROM BANK_0
EE_WRITE_LOOP: MOVFW TMP2 BTFSS CNT1,1 MOVFW TMP1 BANK_1 MOVWF EEDATA BSF EECON1,WREN ;enable write BCF INTCON,GIE MOVLW H'55' MOVWF EECON2 MOVLW H'0AA' MOVWF EECON2 BSF EECON1,WR ;寫(xiě)入 BANK_0
;------- wait --------------------------
MOVLW D'43' ; +=> wait 100mSec MOVWF DELAY_2 ; / L_WaitLoop: CLRF DELAY_1 ; \ CLRWDT ; | BTFSS PIR1,EEIF ; | GOTO L_WaitLoop_TP ; | BCF PIR1,EEIF ; | BANK_1 ; | BCF EECON1,WREN ; | L_WaitLoop1: INCF EEADR,F ; point to EEPROM BANK_0 ; | DECFSZ CNT1,F GOTO EE_WRITE_LOOP INCF ADDRESS,F RETURN
L_WaitLoop_TP: ; | INCFSZ DELAY_1,F ; | GOTO L_WaitLoop+1 ; | DECFSZ DELAY_2,F ; | GOTO L_WaitLoop ; / GOTO L_WaitLoop1 ;
;下面為清除程序,清除地址為00H----3FH,清除值為0FFH,上面一個(gè)是讀子程序一個(gè)是寫(xiě)子程序,但在清除中只用寫(xiě)
;子程序
EEPROM_ERROR: CLRF ADDRESS ; SET EEPROM ADDRESS 0 ERASE_LOOP: MOVLW H'0FF' ; ERASE EEPROM 00-3FH MOVWF TMP1 ; MOVWF TMP2 ; CALL EE_WRITE ; BTFSS ADDRESS,6 ; GOTO ERASE_LOOP ; GOTO RESET ;