EEprom and MCP9801 I2C communication problems


Results 1 to 10 of 10

Threaded View

  1. #1
    Join Date
    Apr 2011
    Location
    NSW, Australia
    Posts
    39

    Default EEprom and MCP9801 I2C communication problems

    Hi

    I am trying to communicate with some I2C chips.
    I am using a Low Pin Count USB development board that has an 18F14K50 Pic.
    Picbasic Pro as the compiler.
    Microchip I2C Serial Eval board. This is connected via the PicKit serial interface. VDD is 3.3V
    I put a pullup resistor to PortB.4 and PortB.6. The value was 4K7. This gave me a voltage level of 0.2V low and 0.6V high
    I changed the SDA resistor to 1K5 and this then gave a high of 2.4V
    By using 'Define SCLOUT 1', I am now at 2.8V on the SCL line

    Attached is the Scope trace when it is trying to read back the data from the EEprom.
    The second trace is when its doing the write command.
    The code is pretty much out of the PBP samples for reading and writing to the EEprom.
    On the I2C Eval board is also an MCP9801 temperature sensing chip. Address 0X92 and I had the same results.
    At this stage I dont know if the problem is hardware, software or both. One thing I can assure you - in the end I will have been the problem!!

    The problem I am having is that when I write to the eeprom, the write value to the address is 100 to 115, but when the read value is returned, I get the value of 16 being read back.
    Similar thing with the MCP9801. I was trying to read back the high and low byte of the temperature registers and getting zero returned.
    Any help would be appreciated. I have been on this for the last 3 days and nearly ready to give up.
    if any more info is required please let me know.


    Code for writing and reading eeprom

    ' PICBASIC PRO program to read and write to I2C SEEPROMs
    '
    ' Write to the first 16 locations of an external serial EEPROM
    ' Read first 16 locations back and send to LCD repeatedly
    ' Note: for SEEPROMs with byte-sized address
    ' Define LCD registers and bits
    DEFINE OSC 12
    Define I2C_slow 1
    Define I2C_SCLOUT 1


    SDA Var PORTB.4 ' Data pin
    SCL Var PORTB.6 ' Clock pin
    B0 Var Byte ' Address
    B1 Var Byte ' Data 1
    B2 Var Byte ' Data 2

    ANSEL = %00000000 ' Set all pins digital
    ANSELH = %00000000

    For B0 = 0 To 15 ' Loop 16 times
    B1 = B0 + 100 ' B1 is data for SEEPROM
    I2CWRITE SDA, SCL, $A0, B0, [B1] ' Write each location
    Serout PORTB.7,0,[#B0, ": ", #B1, " ", 10,13]
    Pause 100 ' Delay 10ms after each write
    Next B0
    mainloop:

    For B0 = 0 To 15 Step 2 ' Loop 8 times
    I2CREAD SDA, SCL, $A0, B0, [B1, B2] ' Read 2 locations in a row
    Serout PORTB.7,0,[#B0, ": ", #B1, " ", #B2, " ",10,13]
    Pause 1000
    Next B0
    Goto mainloop
    End
    Attached Images Attached Images   
    Last edited by aajgss; - 16th April 2011 at 02:17.

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