I2c


Closed Thread
Results 1 to 3 of 3

Thread: I2c

  1. #1
    Mark Scotford's Avatar
    Mark Scotford Guest

    Default I2c

    Can somebody help me please with some sample code. I have not used I2C before and I need to store a variable (B28), with a value between 1-9999 in an external memory EEPROM device, 24A65. All of the device address pins are held down to ground. My code does not work, please can you help.

    HOME1:
    I2CREAD PORTB.4,PORTB.5,%10100000,#B28
    B28 = B28 + 1
    PAUSE 500
    I2CWRITE PORTB.4,PORTB.5,%10100000,#B28
    LCDOut $FE,1,#B28
    PAUSE 500
    GOTO HOME1

    Thanking you in anticipation.
    Mark in Spain

  2. #2
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Mark,

    try the following:

    B28 var word
    Adr VAR Byte

    B28=1245 ' Value to write
    Adr=0 ' EEPROM Location to write to


    I2CWRITE PORTB.4,PORTB.5,%10100000,Adr,[B28]
    Pause 50
    I2CREAD PORTB.4,PORTB.5,%10100000,Adr[B28]

    PAUSE 50

    LCDOut $FE,1,DEC5 B28
    PAUSE 1000

    For reference see PBP Manual Section 5.34 & 5.35

    regards

    Ralph

  3. #3
    Mark Scotford's Avatar
    Mark Scotford Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks Ralph, now I understand.

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. HARDWARE I2C SAMPLE CODE question
    By Michael Wakileh in forum Code Examples
    Replies: 2
    Last Post: - 16th June 2009, 21:07
  3. I2C Master Slave issues.
    By cpayne in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 29th March 2008, 19:33
  4. I2C slave
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th March 2008, 03:46
  5. Please help with i2cslave i2c slave
    By cycle_girl in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st December 2005, 13:55

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