I2C Questions


Closed Thread
Results 1 to 5 of 5

Thread: I2C Questions

  1. #1
    Join Date
    Mar 2008
    Posts
    59

    Default I2C Questions

    I am working 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"

  2. #2
    Join Date
    Dec 2010
    Posts
    409

    Default Re: I2C Questions

    Add the bit to the control address (1110001x) to make a complete byte, where x = 0 or 1 depending on read or write. MSB first is standard so nothing to do.
    Instead of DATAH and DATAL as bytes, use DATA VAR WORD.

    sort of:
    DATAIO VAR PORTA.0
    CLOCK VAR PORTA.1
    CMD_WRITE CON %11100010
    CMD_READ CON %11100011
    DATA VAR WORD

    I2CWRITE DATAIO, CLOCK, CMD_WRITE, [DATA]

  3. #3
    Join Date
    Mar 2008
    Posts
    59

    Default Re: I2C Questions

    Thank You, I continue to have problems and have been reading data sheets, I do not understand this statement in the datasheet "The 7-bit chip address is 7’b0101110 when SEN is high, or is 7’1110001 when SEN is low." the SEN should not have anything to do with the I2C interface The notation of "7’1110001 and 7’b0101110" means nothing to me at this point.

    Thanks for any input!!

    Roger

    Quote Originally Posted by Charlie View Post
    Add the bit to the control address (1110001x) to make a complete byte, where x = 0 or 1 depending on read or write. MSB first is standard so nothing to do.
    Instead of DATAH and DATAL as bytes, use DATA VAR WORD.

    sort of:
    DATAIO VAR PORTA.0
    CLOCK VAR PORTA.1
    CMD_WRITE CON %11100010
    CMD_READ CON %11100011
    DATA VAR WORD

    I2CWRITE DATAIO, CLOCK, CMD_WRITE, [DATA]

  4. #4
    Join Date
    Dec 2010
    Posts
    409

    Default Re: I2C Questions

    I have not used this device, but I had a quick look at the datasheets for you. First, MODE pin should be tied low to put it in I2C mode. When in I2C mode, the SEN (or perhaps SENB) chooses the chip address. I found 2 documents, one calls the pin SEN, the other SENB. "The 7-bit chip address is 7’b0101110 when SEN is high, or is 7’1110001 when SEN is low." So for the example above, tie the SEN(B) pin low. Also you need the address of the register you want to write to, and the two bytes you want to actually write. So to modify what I wrote before:

    DATAIO VAR PORTA.0
    CLOCK VAR PORTA.1
    CMD_WRITE CON %11100010
    CMD_READ CON %11100011
    REGISTER VAR BYTE
    DATA_H VAR BYTE
    DATA_L VAR BYTE

    I2CWRITE DATAIO, CLOCK, CMD_WRITE, [REGISTER,DATA_H,DATA_L]

    When you wish to read, you would first write to set the chip to the right register so you would need to:

    I2CWRITE DATAIO, CLOCK, CMD_WRITE, [REGISTER]
    I2CREAD DATAIO, CLOCK,CMD_READ,[DATA_H,DATA_L]

    Clear as mud?

  5. #5
    Join Date
    Mar 2008
    Posts
    59

    Default Re: I2C Questions

    Thank You!

    Do you think it should be

    "I2CWRITE DATAIO, CLOCK, CMD_WRITE, [REGISTER,DATA_H,DATA_L] or
    I2CWRITE DATAIO, CLOCK, CMD_WRITE, REGISTER,[DATA_H,DATA_L]". I will try your code in the morning at let you know what I find. I am just about to the point of giving up so your input is very much appreciated!I believe my hardware is right however it may be a good idea to do another check? I see 11100011 in my sleep now

    Thank You,

    Roger


    Quote Originally Posted by Charlie View Post
    I have not used this device, but I had a quick look at the datasheets for you. First, MODE pin should be tied low to put it in I2C mode. When in I2C mode, the SEN (or perhaps SENB) chooses the chip address. I found 2 documents, one calls the pin SEN, the other SENB. "The 7-bit chip address is 7’b0101110 when SEN is high, or is 7’1110001 when SEN is low." So for the example above, tie the SEN(B) pin low. Also you need the address of the register you want to write to, and the two bytes you want to actually write. So to modify what I wrote before:

    DATAIO VAR PORTA.0
    CLOCK VAR PORTA.1
    CMD_WRITE CON %11100010
    CMD_READ CON %11100011
    REGISTER VAR BYTE
    DATA_H VAR BYTE
    DATA_L VAR BYTE

    I2CWRITE DATAIO, CLOCK, CMD_WRITE, [REGISTER,DATA_H,DATA_L]

    When you wish to read, you would first write to set the chip to the right register so you would need to:

    I2CWRITE DATAIO, CLOCK, CMD_WRITE, [REGISTER]
    I2CREAD DATAIO, CLOCK,CMD_READ,[DATA_H,DATA_L]

    Clear as mud?

Similar Threads

  1. Beginner I2C Questions
    By rocket_troy in forum Serial
    Replies: 13
    Last Post: - 23rd May 2013, 03:08
  2. I2C howto questions
    By comwarrior in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 27th May 2010, 19:39
  3. i2c PBP questions
    By TimV in forum General
    Replies: 14
    Last Post: - 5th February 2007, 18:58
  4. Questions about i2C EEPROM
    By RunningMan in forum General
    Replies: 3
    Last Post: - 29th January 2007, 05:09
  5. Still new to PicBasic - i2c questions
    By cometboy in forum mel PIC BASIC
    Replies: 4
    Last Post: - 13th November 2006, 19:27

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