I've a strange problem writing internal EEPROM of a 16F628. The code work fine in MPLAB Simulator but not in my circuit. I write data (in EEDATA) from INDF pointed mem locations. The write work fine if I load WREG directly with "movlw" i.e movlw H'AA' then moving it to EEDATA (read back pic eeprom get 'AA') but if i load the EEDATA reg from W after a movf INDF, W then eeprom get all zeroes in any location accesed for write. I'm sure that W is loaded correctly because the value writed is also displayed on a LCD MODULE.
I hope someone can show me the eror of my ways.
Code Chunk:
movlw ROM_NO WRITE_EEPROM_ROM_NO movwf FSR ; W = address of ROM_NO (first byte) movf INDF, W ; Load W with the byte pointed by FSR BANK1 ; MACRO to switch in Bank1 ;movlw H'AA' ; TEST.. WITH THIS DIRECT LOAD WORK!! movwf EEDATA clrf EEADR ; Write at address 00h BSF EECON1, WREN ; Enable write MOVLW H'55' ; MOVWF EECON2 ; Write 55h MOVLW H'AA' MOVWF EECON2 ; Write AAh BSF EECON1, WR ; Set WR bit WRITE_EEPROM_WAIT
btfsc EECON1, WR ; Wait for wrinting goto WRITE_EEPROM_WAIT ... ...
Thanx Alex