I2C Questions


Closed Thread
Results 1 to 5 of 5

Thread: I2C Questions

Hybrid View

  1. #1
    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?

  2. #2
    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, 02:08
  2. I2C howto questions
    By comwarrior in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 27th May 2010, 18:39
  3. i2c PBP questions
    By TimV in forum General
    Replies: 14
    Last Post: - 5th February 2007, 17:58
  4. Questions about i2C EEPROM
    By RunningMan in forum General
    Replies: 3
    Last Post: - 29th January 2007, 04:09
  5. Still new to PicBasic - i2c questions
    By cometboy in forum mel PIC BASIC
    Replies: 4
    Last Post: - 13th November 2006, 18:27

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