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
hi art im newbe but if im right i noticed an error in your code .sorry if its not.
hope this helpsCode:W0 var byte epin var word <<<<< i think this is address ? W0 = 0 FOR cntr = 0 TO 2000 'should be( FOR epin= 0 TO 2000 )! or (cntr)should be var xxx epin = epin + 5 ' I2CWRITE porte.1,porte.2,%10100000,epin,[W0,W0,W0,W0,W0],error pause 10 ' ' NEXT cntr
see Gusse code moght it helps
Last edited by MR2010; - 26th January 2010 at 07:08.
hi gusse guess SDA PORTD.1 is always input what will happens ? u did set SDA port input only read .u have to leave trisd alone and set portd = 0 , i can say trisd s gone to charge you lol
im newbe hope this helpsCode:TRISD.0 = 0 TRISD.1 = 1 '<<<should be TRISD.1 = 0 or only PORTD = %0000 TRISD.3 = 0 TRISE.4 = 0 SCL VAR PortD.0 SDA VAR PortD.1 LED VAR PortD.3 END
hope u get better gusse
regards
Last edited by MR2010; - 26th January 2010 at 08:01.
To my understanding I2CWRITE and I2CREAD -functions take care of port settings. So basically, whatever user is pre-defining in SW, I2C-routine will over-write it.
- I2C clock is always coming from master (PIC) and it is output.
- I2C data is bi-directional, so port will change between input and output.
Please, somebody wiser correct if I'm totally wrong.
Value should be 1023. 0 + 1023 = 1024.Code:I2CAddressEEprom = 0 TO 1024
BR,
-Gusse-
PS. Getting better, little by little ...
Last edited by Gusse; - 26th January 2010 at 09:37.
Yes epin is an address word but it is incremented by the line:
epin = epin + 5 in the code I provided.
This is correct because the I2CWRITE command has written five addresses sequentially.
The cntr var should be declared at the top, I forgot that.
Hi Dave,Art, I have used external eeproms on most all of my projects and have never had any problems with bad data.
Solar electricity rules, and if you use it to run a fridge it slaps nature in the face
I'll try a paralel resistor value to equal 2.2K, and retry the DEFINE I2C_SLOW 1.
Normally I don't have problems with EEPROMS either.
One other thing.
I have introduced five new byte vars, and done a readback of the five
written bytes so the program can verify what was read from the EEPROM is
the same as what was written 10ms ago.
If the results don't match, it goes back to rewrite the original (correct) values.
When it gets to one of the addresses in question, it just hangs there
rewriting all the time, and never getting the data right.
I JUST DESCOVERED THE BLOODY PROBLEM IS
WHEN U PUT VAR BYTE IT WORKS GREAT BUT WHEN U PUT VAR WORD IT DOESNT IT WRITES ONLY 4TH BYTE .IM CONFUSED THE PROBLEM IS IN THE ADRESS OR THE DATA X,Code:I2CAddressEEprom VAR WORD
HOPE U CAN FIND IT GUYS
GOOD LUCK ..!
Last edited by MR2010; - 26th January 2010 at 10:56.
Whether you use a word or byte address depends on the EEPROM device.
It's in the manual for I2CREAD.
Address size depends on EEPROM size (see table)
PicBasic Manual I2C -part
(2 bytes = 1 word)
Manual is Your friend
BR,
-Gusse-
Last edited by Gusse; - 26th January 2010 at 11:24. Reason: Repeating same as Art ;)
Last edited by MR2010; - 26th January 2010 at 11:24.
Bookmarks