Problem with I2C (24c32 eeprom)


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Location
    Bellevue
    Posts
    125


    Did you find this post helpful? Yes | No

    Default

    I have a similar issue, but have an idea that might help a little..

    Have you added a 'failed' lable routine to the I2Cread or write command so you can tell if it is failing ..?

    I use this:

    I2CWRITE DPIN,CPIN,Chip1,Address,[STR array\36],failw

    and

    I2CREAD DPIN,CPIN,Chip2,address,[STR array\36],failr

    ... program ....


    failw:
    Serout2 SO,BD,["Write Failed",10,13] ' Spaces
    return

    failr:
    Serout2 SO,BD,["Read Failed",10,13] ' Spaces
    return

    Where 'failw is a routine that tells me what happened.

    HOWEVER!! I have the same problem you are having - no I2C data!! I have just moved to an 18F2525, and cannot for the life of me figure out how to turn on the settings for I2C on C3, C4 which are the SLC and SDA pins..

    My program just keeps saying it is failing..

    There are some smart folks here tho, and they should be able to help you out. I'll watch the thread & maybe learn something for the 18F2525 too..

    Tom

  2. #2
    Join Date
    Feb 2005
    Location
    Bellevue
    Posts
    125


    Did you find this post helpful? Yes | No

    Thumbs up

    OK.. I got data back on I2C from the 18F2525! Different than the 877, but perhaps some of what I just figured out will help you...

    I am using 24LC512 units, I have two chips wired for addressing as follows:

    Chip1 - A0=0,A1=0,A2=0
    Chip2 - A0=1,A1=0,A2=0

    So, the chips can now be called as follows:

    Chip1 con %10100000 ' address of chip1
    Chip2 con %10100010 ' address of chip2

    ' -----[ Program Description ]---------------------------------------------
    ' EEPROM PIN EEPROM PIN NAME PIC PIN MISC
    ' EEPROM.1 A0
    ' EEPROM.2 A1
    ' EEPROM.3 A2
    ' EEPROM.4 Vss
    ' EEPROM.5 SDA SDA RC4 DPIN - data
    ' EEPROM.6 SCL SCL RC3 CPIN - clock
    ' EEPROM.7 WP
    ' EEPROM.8 Vcc

    Using a setting I THINK is appropriate for this PIC for the I2C master setting from the spec sheets. (I don't know if this is rigth or not, but it seems to be working..)

    SSPCON1 = %11011100
    SSPCON2 = %01111000

    Using RC3, RC4 on the PIC as SLC and SDA:
    DPIN var PortC.4 ' I2C data
    CPIN var PortC.3 ' I2C clock

    My calls then look like this:

    I2cwrite DPIN, CPIN, Chip1, address,[$02,$47,STR SSMAX\34],failw

    -- and --

    I2cread DPIN, CPIN, Chip1, address,[STR SSOUT\36],failr

    And it is working well! If you can't get it working, check the MCP sheet for the pic, and look for the register settings for the IC2..

    TG

  3. #3
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Like Mulder always said in the X-Files "the answer is out there..."

    http://www.picbasic.co.uk/forum/showthread.php?t=587

    All you got to do is look for it.

  4. #4
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    Hi Tom,
    As far as my small bit of understanding goes - I2Cread/write are software-only routines - and do not use the I2C 'hardware' that is built in to some PICs.
    I've been tinkering with I2Cread/write on a 16F628, which has no I2C hardware, and it works fine.

    Arch

  5. #5
    Join Date
    Feb 2005
    Location
    Bellevue
    Posts
    125


    Did you find this post helpful? Yes | No

    Default

    When I refer to 'hard wiring' addresses I am talking about the addressing of multiple EEPROMS on the bus. By physically connecting A0, A1, A2 (in the case of the 24LC512 anyway), one sets up an address for each chip so it can be referenced on the I2C bus....

  6. #6
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    Hi Tom,
    Yup, I learned about those address bits recently. I was talking about your setting up of the "MASTER SYNCHRONOUS SERIAL PORT (MSSP) MODULE" and its associated SSPCON registers.
    Since PBP's I2Cread/write commands are all done in software, you should not need to configure the 'hardware' serial port module - except maybe to turn it off.

    Arch

Similar Threads

  1. I2C Master/Slave 16F88/16F767 working code
    By DanPBP in forum Code Examples
    Replies: 2
    Last Post: - 23rd October 2012, 22:31
  2. Problem with I2C EEPROM addressing
    By Atom058 in forum General
    Replies: 14
    Last Post: - 3rd November 2009, 03:17
  3. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 21:07
  4. Another I2C Slave Routine Problem
    By DanPBP in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th February 2009, 05:50
  5. I2C eeprom and DS1307 @40MHz problem
    By ius01 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 20th July 2007, 07:41

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