I2CWRITE problem


Closed Thread
Results 1 to 36 of 36

Hybrid View

  1. #1
    Join Date
    Dec 2007
    Location
    Finland
    Posts
    191


    Did you find this post helpful? Yes | No

    Post Minä tyhmä - Me dummy

    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-

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Gusse View Post
    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-
    Don't be so hard on yourself, people (especially sick ones) make mistakes.
    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.

  3. #3
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    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

  4. #4
    Join Date
    Jan 2010
    Location
    morocco
    Posts
    16


    Did you find this post helpful? Yes | No

    Default

    hi art im newbe but if im right i noticed an error in your code .sorry if its not.
    Code:
    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
    hope this helps
    see Gusse code moght it helps
    Last edited by MR2010; - 26th January 2010 at 06:08.

  5. #5
    Join Date
    Jan 2010
    Location
    morocco
    Posts
    16


    Did you find this post helpful? Yes | No

    Question

    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

    Code:
    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
    im newbe hope this helps
    hope u get better gusse
    regards
    Last edited by MR2010; - 26th January 2010 at 07:01.

  6. #6
    Join Date
    Dec 2007
    Location
    Finland
    Posts
    191


    Did you find this post helpful? Yes | No

    Post

    Quote Originally Posted by MR2010 View Post
    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 helps
    hope u get better gusse
    regards
    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.

    Code:
    I2CAddressEEprom = 0 TO 1024
    Value should be 1023. 0 + 1023 = 1024.

    BR,
    -Gusse-

    PS. Getting better, little by little ...
    Last edited by Gusse; - 26th January 2010 at 08:37.

  7. #7
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by MR2010 View Post
    hi art im newbe but if im right i noticed an error in your code .sorry if its not.
    Code:
    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
    hope this helps
    see Gusse code moght it helps
    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.

    Art, I have used external eeproms on most all of my projects and have never had any problems with bad data.
    Hi Dave,
    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.

  8. #8
    Join Date
    Jan 2010
    Location
    morocco
    Posts
    16


    Did you find this post helpful? Yes | No

    Default

    I JUST DESCOVERED THE BLOODY PROBLEM IS
    Code:
    I2CAddressEEprom    VAR WORD
    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,

    HOPE U CAN FIND IT GUYS
    GOOD LUCK ..!
    Last edited by MR2010; - 26th January 2010 at 09:56.

  9. #9
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default

    Whether you use a word or byte address depends on the EEPROM device.
    It's in the manual for I2CREAD.

Similar Threads

  1. My I2CWRITE - timings and tricks
    By FinchPJ in forum Code Examples
    Replies: 5
    Last Post: - 3rd March 2008, 21:40
  2. Problem with I2Cread and I2CWRITE function
    By Tony85 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th June 2006, 20:03
  3. Problem with I2Cread and I2CWRITE function
    By Tony85 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 6th June 2006, 18:32
  4. Another I2CWRITE problem
    By ErnieM in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 20th May 2006, 21:57
  5. I2CRead / I2CWrite Problem?
    By koossa in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st October 2005, 18:26

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts