Just a couple of things to check/try...
Check:
ADC turned off for E.1 and E.2
Try:
DEFINE I2C_SLOW
Just a couple of things to check/try...
Check:
ADC turned off for E.1 and E.2
Try:
DEFINE I2C_SLOW
Dave
Always wear safety glasses while programming.
Yep, I have all digital pins. The EEPROM works most of the time,ADC turned off for E.1 and E.2
Try:
DEFINE I2C_SLOW
it just doesn't want to write some addresses.
DEFINE I2C_SLOW 1 made no difference.
No interrupts in this program either.
4.7K pullups, checked 5 Volt supply.
Hi Art & All,
Thanks to Art, I noticed similar I2CWRITE problem with different PIC and EEPROM (I use 18F4520 and 24C64).
So far I haven't use external EEPROM for storing anything, just used I2CREAD and that has worked very well.
Below is my test code for WRITE/READ for EEPROM. Test will be passed if X=0 (LED blinking slowly), if X > 0 then it fails immediately (LED blinking fast).
No help from DEFINE I2C_SLOW or any other that I have tried so far (increasing PAUSE time between write and read, etc...).Code:<code><font color="#000000">OSCCON = $70 <font color="#000080"><i>'Int CLK 8MHz </i></font>OSCTUNE.6 = 1 <font color="#000080"><i>'PLL 4x </i></font>ADCON1= %00001111 <font color="#000080"><i>'$0F = disable A/D converter </i></font>TRISD.0 = 0 TRISD.1 = 1 TRISD.3 = 0 TRISE.4 = 0 <b>DEFINE </b>OSC 32 X <b>VAR BYTE </b>Y <b>VAR BYTE </b>SCL <b>VAR </b>PortD.0 SDA <b>VAR </b>PortD.1 LED <b>VAR </b>PortD.3 I2CDeviceEEprom <b>VAR BYTE </b>I2CAddressEEprom <b>VAR WORD </b>I2CDeviceEEprom=$A0 X=0 <font color="#000080"><i>'OK if EEPROM content is 00h and X = 0, if X > 0 then fails </i></font><b>FOR </b>I2CAddressEEprom = 0 <b>TO </b>8191 <b>I2CWRITE </b>SDA, SCL, I2CDeviceEEprom, I2CAddressEEprom,[ X ], Error <b>PAUSE </b>10 <b>I2CREAD </b>SDA, SCL, I2CDeviceEEprom, I2CAddressEEprom,[ Y ], Error <b>IF </b>Y <> X <b>THEN GOTO </b>Error <b>NEXT </b>I2CAddressEEprom Blink: <b>HIGH </b>LED <b>PAUSE </b>1000 <b>LOW </b>LED <b>PAUSE </b>1000 <b>GOTO </b>Blink Error: <b>HIGH </b>LED <b>PAUSE </b>200 <b>LOW </b>LED <b>PAUSE </b>200 <b>GOTO </b>error <b>END</b> </code>
Hardware is OK, because I have used it for other purpose and then PIC read only from EEPROM (same PIC and EEPROM). Pull-ups are 4.7k and very solid 5V (no dips). Data lines are quite short (~25mm). EEPROM is only device in I2C-bus. WP pin is grounded....
Sounds very similar problems as Art has.
BR,
-Gusse-
Last edited by Gusse; - 25th January 2010 at 16:37.
Hi Gusse,
Your code does not loop, I am sitting here wondering if there is some latency in your hardware, causing your code to run ahead of the eeprom, so the code is finished before the eeprom has finished waking up . . . Maybe in Art's too . . BTW ART, I liked your talking clock, esp when it encounters an error![]()
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
My code is working well
I found a reason for problem and I must admit it is purely due to my own stupidity. I have two identical (home made) test boards and when I measured I2C voltage, I measured from wrong board. Board which had I2C test SW was not properly powered. Meaning that one of the PIC IO pin is supply for I2C and that pin was not set to "1". No power, no EEPROM. How stupid of me!
It might have something to do that this is my fourth day in flu and fever. Brains are not anymore working well...
BR,
-Gusse-
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Art, I have used external eeproms on most all of my projects and have never had any problems with bad data. I just make sure I dont have any interrupts during the write cycle and always use 2.2k resistors for the pullups. I am currently using 2 x 24LC1025's for about a months worth of data storage on a solar telemetery project and haven't had a bad bit all summer or winter. So far its been -5 degrees a couple of nights here.. I would suggest maybe using 2.2k resistors for the pullups and the I2C_SLOW command. I also never use more than 6 milliseconds of delay after the write... Good Luck...
Dave Purola,
N8NTA
Thanks for the comments, but I don't know what you mean by the code running ahead of the EEPROM.
The code is posted above. Writing a bunch of zeros is not exactly what I want to
achieve, but the code exhibits the problem I'm describing.
I suppose at some point I'll run the same code on a breadboard and try adjusting things like clock speed, pull up resistor values, and see if that helps.
PBP should compensate for clock speed though.
HI art IM JUST TESTING IT ON AN OLD PIC F84A WITH 24C08 ITS WORKING WELL
THIS MY CODE MODIFIED GUSSE CODE
YOU HAVE TO MAKE SURE ABOUT EEPROM PULLUPS AND TRIS AND PORT SET THEM TO 0 OUTPUTCode:PORTB = 0 TRISB = 0 X VAR BYTE Y VAR BYTE SCL VAR PortB.0 SDA VAR PortB.1 LED VAR PortB.3 I2CDeviceEEprom VAR BYTE I2CAddressEEprom VAR WORD I2CDeviceEEprom=$A0 X=0 'OK if EEPROM content is 00h and X = 0, if X > 0 then fails MAIN: FOR I2CAddressEEprom = 0 TO 1024 I2CWRITE SDA, SCL, I2CDeviceEEprom, I2CAddressEEprom,[ X ], Error PAUSE 10 I2CREAD SDA, SCL, I2CDeviceEEprom, I2CAddressEEprom,[ Y ], Error IF Y <> X THEN GOTO Error IF I2CAddressEEprom = 1024 AND X = Y THEN BLINK NEXT I2CAddressEEprom GOTO MAIN Blink: HIGH LED PAUSE 1000 LOW LED PAUSE 1000 GOTO Blink Error: HIGH LED PAUSE 200 LOW LED PAUSE 200 GOTO error END
JUST LOOK TO THIS CODE TO GET SOME IDEAS OR POST UR WHOLE CODE SO EVERYONES CAN HELP .
REGARDS
Last edited by MR2010; - 26th January 2010 at 08:00.
Hi Art,
I was thinking, in Gusse's case, the pic might blather out a bunch of commands before his eprom was awake, since he is using an OFF PIC eprom, and maybe the eprom just missed it due to the difference in boot rates. I was thinking a short pause during initialization might allow eprom to catch up . . . as I said, I was just thinking.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Bookmarks