PDA

View Full Version : Pic16F628A and 24LC256 EEPROM I2C



Mike96
- 24th December 2005, 16:04
Is this hookup valid for I2C EEPROM storage of data?
(see .JPG file)
First EEPROM is Address $00 and the other Address $01

Part of PicBASIC Pro program follows:

' **********************************************
' Using PIC16F628A and 24LC256 EEPROMs
' **********************************************
SCLK VAR PORTB.6 ' Data Pin on I2C
SDATA VAR PORTB.7 ' Clock Pin on I2C
addr VAR WORD ' Memory location in EEPROM to use
CntRec VAR WORD ' Value of count to store in EEPROM

addr = %00000001 ' Location of memory to use
CMCON = 7 ' PORTA digital

' if power is applied, want last count of data stored in EEPROM -
' Read EEPROM first to get last count

I2CREAD SDATA,SCLK,$A0,addr,[CntRec]

GOSUB LCD_Display01 : Display count from EEPROM
' Send CntRec out to Serial bus or LCD Display to display content

Main:
If DET_IN = 1 THEN ' any form of detector circuit
CntRec = CntRec + 1 ' Increment count in EEPROM
GOSUB LCD_Display01
IF CntRec >= 255 THEN
CntRec = 1
GOSUB LCD_Display04 ' reset count
EndIf
EndIf

I2CWRITE SDATA,SCLK,$A0,addr,[CntRec] ' Write new count

GOTO Main ' continuous loop ....

LCD_Display01:
LCDOUT CMD, Line1, "* * * * * * * Detected Signal * * * * *"
LCDOUT CMD, Line2, " Detect Total = " ,#CntRec, " "
RETURN

LCD_Display04:
LCDOUT CMD, Line1, "* * * * * * * Reset Count * * * * * * *"
LCDOUT CMD, Line2, " EEPROM = " ,#CntRec, " "
PAUSE 5000 ' pause for 5 seconds
RETURN

Melanie
- 24th December 2005, 17:27
1. Remove R22... connect directly to Vdd/+5v.

2. Remove R23 & R24, connect directly to Vss/0v.

3. Value of 10K is too high for R25 & R26. Drop it to 4K7.

Merry Christmas (or Happy Holidays - whichever you prefer) to all...

Mike96
- 24th December 2005, 20:01
Found problem with a connection to the 24LC256 chip.

Apperently, the connection to the SCL (clock) line was not making contact to Pin 6 of the chips. After getting the connection to then, the circuit worked flawlessly.

Originally my story was that I used to use the PIC16F628A internal EEPROM memory, but when a new chip was inserted (programmed ), the count was lost.

So finally I relized that external Ram was the key.

Hooking up the 24LC256 in a SOIC package, I used the wrong connection (unused wire) to put pull-up on clock signal. After connecting the proper line to the chips, the circuit worked.

Here is a complete program and schematic for 24LC256:

See Attachments

Thank You

Mike96
- 1st January 2006, 03:13
I do not know the 24LC515 chip but post your PIC BASIC text file and I will look at it to see where your error might be.

I need to know what is your clock frequency and PIC Chip Type ( 16FXXX ).