0
我有一個任務來爲PIC16F84單片機寫入eeprom讀/寫子程序。我寫過這樣的代碼:PIC16F84 - eeprom讀取和寫入
EEPROM_Read
clrw
bsf STATUS, RP0 ; Bank0
movlw DATA_EE_ADDR ; Any location in Data EEPROM memory space
movwf EEADR ; Address to read
bsf EECON1, RD ; EE Read
movlw EEDATA
bcf STATUS, RP0 ; Bank0
return
EEPROM_Write
bcf INTCON,GIE ;disable interrupts for EEPROM write
banksel EEADR ;bank 2
movfw DATA_EE_ADDR ;load write address to EEPROM address pointer
movwf EEADR
movfw DATA_EE_DATA ;load write data to EEPROM data buffer
movwf EEDATA
banksel EECON1 ;bank 3
bsf EECON1,WREN ;enable EEPROM write
movlw 0x55 ;unlock codes
movwf EECON2
movlw 0xAA
movwf EECON2
bsf EECON1,WR ;enable EEPROM write
btfsc EECON1,WR ;wait here until write completes
goto $-1
bcf EECON1,WREN ;write complete, disable write mode
banksel 0 ;bank 0
movlw 0 ;are interrupts being used?
xorwf INTCON,W
btfss STATUS,Z
bsf INTCON,GIE ;yes,enable interrupts
return
是不是正確?我有EEProm_Read的問題。它似乎並不正確。