Page 1 of 1

18F4431 asm how to read EEPROM (internal)

PostPosted: Tue Jan 22, 2019 4:16 pm
by Michael
Where do I have error or what should I declare/configure to read internal 18F4431 EEPROM?

eeprom_loop
movf EE_count, W; move EEPROM address to W

;next lines copied from Microchip 18F44321 data sheet
MOVWF EEADR ; Data Memory Address to read
BCF EECON1, EEPGD ; Point to DATA memory
BSF EECON1, RD ; EEPROM Read
MOVF EEDATA, W ; W = EEDATA

;my code continued
movwf EE00; move EEPROM data to my EE00 variable
call display_EEPROM; my working LCD display routine
incf EE_count; next EEPROM address to read
call 1second_delay
goto eeprom_loop

18F4431 runs @ 40MHz with 10 MHz crystal and 4x pll

Michael niepsycholog@gmail.com

Re: 18F4431 asm how to read EEPROM (internal)

PostPosted: Wed Jan 23, 2019 1:09 pm
by ric

Re: 18F4431 asm how to read EEPROM (internal)

PostPosted: Wed Jan 23, 2019 1:26 pm
by Michael
SOLVED
Microchip forgot to add one more line in EEPROM reading example in their 18F4431 data sheet.
That is setting one more bit:
BCF EECON1, CFGS ; Access EEPROM

finally it should be:
MOVWF EEADR ; Data Memory Address to read
BCF EECON1, EEPGD ; Point to DATA memory
BCF EECON1, CFGS ; Access EEPROM; this line should be inserted here
BSF EECON1, RD ; EEPROM Read
MOVF EEDATA, W ; W = EEDATA