PDA

View Full Version : I'm having problems with reading a AT24C1024 EEPROM



Fernandocsouza
- 14th May 2014, 18:01
You guys can help me hello
I'm having problems with reading a AT24C1024 EEPROM,
I'm able to read a line of information, would like to know how to perform the reading of the other lines because the messages are displayed on the LCD with characters on black

Here is the code

DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 1
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 2
TRISB = 0
CMCON = 7

SCL var PORTA.0 ' Clock pin
SDA var PORTA.1 ' Data pin


E0 var byte
B1 var byte ' Data 1
B2 VAR BYTE

b1 = e0 + $00 'B1 is dados da EEPROM 'not sure what you are using E0 + $20 for?
B1 = E0 + $10
ADDR var WORD ' 24c32a uses 2 bytes for address ( 12 bits, high 4 bits are 0's )
ADDR = 0 ' where in eeprom to store first byte, I chose 0 (start of eeprom)


pause 100
I2CWRITE SDA,SCL,$A0,ADDR,[16,"pic basic pro "] ' "pic basic pro" is 16 characters long
pause 100
I2CWRITE SDA,SCL,$A1,ADDR,[16,"Mechatronics "]
LCDOUT $FE,1 'clear &home lcd screen (change this to position on screen you want your data)
pause 100

ADDR = 0
WHILE ADDR < 16 'Character Loop to read the 16 bytes "pic basic pro"
I2CREAD SDA,SCL,$A0,ADDR,[b1] 'read byte from eeprom
lcdout b1 'display byte on lcd
ADDR = ADDR + 1 'advance address to next eeprom location
pause 100
I2CREAD SDA,SCL,$A0,ADDR,[b2]


wend 'done with all of string

pause 100
lcdout $FE, $0C
pause 100

Dave
- 15th May 2014, 13:44
You really need to read the manual page 158 on I2CWRITE as the way you are using it is all wrong. You can not expect to write a string to a page like you are doing. Also you are writing the second string to another AT24C1024 from the looks of it. Is this correct?