I2CREAD and I2CWRITE problems


Closed Thread
Results 1 to 2 of 2

Hybrid View

  1. #1
    yourmomOS's Avatar
    yourmomOS Guest

    Angry I2CREAD and I2CWRITE problems

    All,
    I am having real problems with an i2c eeprom. I have read the datasheet and can not find the answer I am looking for. I am using a 16f628 and a 24LC512. I can not seem to get any real data from the eeprom. I have both clock and data pulled high with 4.7k. Here is just one of the code samples I have tried. On this one I finally was just trying to write a simple letter into the eeprom. I tried number, letters, variables. All I am getting on the screen is a smiley face!? Can someone help please?

    define OSC 20
    CMCON = 7 'TURN OFF COMPARATOR
    'Include "modedefs.bas" ' Include serial modes

    SO con 0 ' Define serial output pin
    DPIN var PORTA.0 ' I2C data pin
    CPIN var PORTA.1 ' I2C clock pin
    B0 var word
    B1 var byte
    symbol control = %11010000


    For B0 = 0 To 15
    B1 = B0 ' Loop 16 times
    I2CWRITE DPIN,CPIN, control,$A0,B0,["B"] ' Write each location's address to itself
    Pause 10 ' Delay 10ms after each write
    Next B0
    SEROUT2 PORTB.2, 84,["WRITE COMPLETED", 10, 13]
    loop: For B0 = 0 To 15 step 2 ' Loop 8 times
    I2CREAD DPIN,CPIN, control, $A0,B0,[B1] ' Read 2 locations in a row
    pause 10
    serout2 PORTB.2, 84,[B1]
    Next B0

    serout2 PORTB.2, 84, [10, 13]


    Goto loop

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


    Did you find this post helpful? Yes | No

Similar Threads

  1. I2CRead & I2CWrite not working as expected
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 30
    Last Post: - 27th October 2021, 18:36
  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. PFC8583 Connection and I2Cwrite I2cread!
    By uludere72 in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 27th February 2006, 13:32
  5. I2CWRITE and I2CREAD
    By Tomas in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 23rd April 2004, 02:30

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