Hi folks:
I need some help getting an EEPROM to respond and hold data..
I have a test program that ONLY tries to write 100 then read values to an external 24LC515 EEPROM part. I have scoured the boards and the MCP docs, but have been unable to get this simple little program to work. The example programs use var byte, and this chip needs var word, so that has been made. Here is the program - any ideas why it spits out '0' for all the stored values instead of a count from 1-100 ???
' I2CREAD and I2WRITE Commands - Two 24LC515 chips
'
' Write to the first 100 locations of an external serial EEPROM - 24LC515
' Read first 100 locations back and send to serial out repeatedly
' Note: using WORD as variable
' EEPROM PIN EEPROM PIN NAME PIC PIN MISC
' EEPROM.1 A0 Gnd/VCC depending on chip
' EEPROM.2 A1 Gnd/VCC depending on chip
' EEPROM.3 A2 Vcc
' EEPROM.4 Vss Gnd
' EEPROM.5 SDA SDA 1K resistor RA0 DPIN - data
' EEPROM.6 SCL SCL RA1 CPIN - clock
' EEPROM.7 WP Gnd
' EEPROM.8 Vcc Vcc
' Chip1 = AO is low, A1 is low
' Chip2 = AO is high, A1 is low
' 24LC515 address is '1010'
' address '1010', '0', chip select bits, read/write bits
Include "modedefs.bas" ' Include serial modes
SO var PortB.4 ' out to GPS
BD con 16572 ' 4800b driven inverted none (eliminate need for max232)
' **************************EEPROM ****************************************
DPIN var PortA.0 ' I2C data
CPIN var PortA.1 ' I2C clock
address var word
value var word
Chip1 con %10100000 ' address of chip1
Chip2 con %10100100 ' address of chip2
B0 var word
B1 var byte
B2 var byte
' write stuff into memory
For Address = 0 To 100
I2CWRITE DPIN,CPIN,Chip1,Address,[Address] ' Write each location's address to itself
Pause 10 ' Delay 10ms after each write
Next Address
For Address = 100 To 0 step -1
I2CWRITE DPIN,CPIN,Chip2,Address,[Address] ' Write each location's address to itself
Pause 10 ' Delay 10ms after each write
Next Address
loop:
' Chip 1 output
Serout2 SO,BD,["Chip 1",10,13] ' Name
For Address = 0 To 100 step 2
I2CREAD DPIN,CPIN,chip1,Address,[B1,B2] ' Read 2 locations in a row
Serout2 SO,BD,["Address: ", #address," B1: ", #B1," B2: ",#B2,10,13] ' Print 2 locations
Next Address
Serout2 SO,BD,[10,13,10,13,10,13] ' Spaces
' Chip 2 output
Serout2 SO,BD,["Chip 2",10,13] ' Name
For Address = 0 To 100 step 2
I2CREAD DPIN,CPIN,chip1,Address,[B1,B2] ' Read 2 locations in a row
Serout2 SO,BD,["Address: ", #address," B1: ", #B1," B2: ",#B2,10,13] ' Print 2 locations
Next Address
Serout2 SO,BD,[10,13,10,13,10,13] ' Spaces
Goto loop
Bookmarks