explanation on I2C command (PBP)


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2005
    Location
    France
    Posts
    97

    Arrow explanation on I2C command (PBP)

    hello
    In the ONLINE help I found the I2C command explanation, see below

    I2CWRITE DataPin,ClockPin,Control,{Address,}[Value{,Value...}]{,Label}

    I2CWRITE sends Control and optional Address out the I2C ClockPin and DataPin followed by Value.

    Questions :
    1/ what is the meaning of CONTROL ? for me an I2C device as
    a one byte adress (let's say 00 to FF) control is optional in this case ?
    2/ what the meaning of LABEL, I mean goto this label on which state or result
    if command well done or in case of error (I suppose error case )
    I didn't find any explanation on thoses terme.
    thanks in advance
    F1CHF Francois

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


    Did you find this post helpful? Yes | No

    Default

    control is the device Address which you will determine by reading the DATASHEET for that device...

    Example 1... for a DS1307 RTC chip, this Address is $D0.
    Example 2... for a 24LC64 EEPROM, this address is in the range $A0-$AE.
    Example 3... for an MCP23008 I/O Port Expander, the Address is $40-$4E.

    It means you can have multiple devices co-existing on the same bus, as each will have their own unique device address, and will only respond to their own control byte.

    Label is as you've already determined, the Label which the program will jump to if there is an error... in this case the I2C slave device fails to respond with an acknowledge. (it is actually in the manual). You can make use of this feature to easily detect if an optional device has been installed.

  3. #3
    Join Date
    Jan 2005
    Location
    France
    Posts
    97


    Did you find this post helpful? Yes | No

    Arrow explanation on I2C command

    well well Thanks Melanie for your nice and quick answer (as usual !)
    may I come back on the control and adress parameters
    I understand :
    CONTROL is the physical adress of the I2C slave as you said $A0 to $AE for the 24LC64
    ADRESS is an optional parameter (in this case a memory location in this eeprom) this parameter is a BYTE so the maximal value is $FF (dec 256)
    and the 24LC64 need a 12 bits adress regarding the size.

    It is not the case for a SP5055 or PCF8574 which have only ADRESS and
    two bytes of data .... in this case parameter adress is ignored ?

    I2Cwrite sda,scl, @I2C,[data1, data2], error routine label

    Am I right ?, or still "swiming in the marmelade ?"

    last sentence is a French translation .. hi ! like me ...
    so , sorry for my possible bad translation or writing.

    regards,
    Francois

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


    Did you find this post helpful? Yes | No

    Default

    You're pretty much there... except...

    24LC32 has a BYTE as the Control Address and a WORD as the Memory Address.

    Without looking at the Datasheets for those two devices you quoted I can't say, but EEPROMs for example need the Memory Address, other devices (like the RTC or I/O Expander) don't so you omit it, however in many cases it is replaced by an internal REGISTER Address for the I2C Slave Device. Again refer to your Datasheet for your particular I2C Slave device.

    Example for DS1307 RTC...

    I2CAddress=$D0 ' Device Address
    I2CRegister=0 ' Get Seconds Register
    I2CRead SDA,SCL,I2CAddress,I2CRegister,[DataA],I2CDataError

    If swimming in marmalade - bring some toast...

  5. #5
    Join Date
    Mar 2008
    Posts
    59


    Did you find this post helpful? Yes | No

    Default Re: explanation on I2C command (PBP)

    Melanie

    I am having a time with the RDA1846, the data sheets says the 7 bit control address is 1110001 plus a read/write bit does I2CWRITE add this read/write bit in the proper place or do I need add it to the control address? It also says it should be sent MSB first is this how I2CWRITE handles this control byte? I am very confused !

    ADDRESS VAR BYTE
    DATAH VAR BYTE
    DATAL VAR BYTE
    I2CWRITE DATAIO,CLOCK,%1110001,ADDRESS,[DATAH,DATAL]

    Thanks You!
    https://dallasmakerspace.org/w/image...ing_manual.pdf "Page 5"

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 : 1

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