Quick question - how to use 0x27 as an address in i2c


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2009
    Posts
    583

    Default Quick question - how to use 0x27 as an address in i2c

    I'm wanting to write to an address of 0x27. PBP seems to suggest that $42 is the format to use, although most conversion charts state that this is 39 not 42 ?

    I'm confused as I have two i2c piggy back boards that use I2C and code written to it in PBP fail to do anything to the display (but work fine over serial). I've tried $42 $39 $4E and still it fails to do simple task like turn the backlight off etc)

  2. #2
    Join Date
    Jan 2013
    Location
    Texas USA
    Posts
    229


    Did you find this post helpful? Yes | No

    Default Re: Quick question - how to use 0x27 as an address in i2c

    From the Digole datasheet
    "I2C: Slave Mode, 7-bit address, default address is Hex:27"

    $27 <<1 = $4E (moves address to upper 7-bits and adds the R/W bit to bit0.

    This is the address you use in the I2CWRITE AND I2CREAD commands.


    I2C Device Addressing
    All I2C addresses are either 7 bits or 10 bits. The use of 10 bit addresses is rare and is not covered here. All of our modules and the common chips you will use will have 7 bit addresses. This means that you can have up to 128 devices on the I2C bus, since a 7bit number can be from 0 to 127. When sending out the 7 bit address, we still always send 8 bits. The extra bit is used to inform the slave if the master is writing to it or reading from it. If the bit is zero the master is writing to the slave. If the bit is 1 the master is reading from the slave. The 7 bit address is placed in the upper 7 bits of the byte and the Read/Write (R/W) bit is in the LSB (Least Significant Bit).

    Name:  image.jpg
Views: 295
Size:  10.6 KB

    The placement of the 7 bit address in the upper 7 bits of the byte is a source of confusion for the newcomer. It means that to write to address 21, you must actually send out 42 which is 21 moved over by 1 bit. It is probably easier to think of the I2C bus addresses as 8 bit addresses, with even addresses as write only, and the odd addresses as the read address for the same device.


    PBP's I2CWRITE and I2CREAD commands require the R/W bit of the Slave address to be 0. PBP will automatically change the R/W bit by itself when it sends the actual bits to the I2C slave device.

    From the PBP manual.
    "The upper 7 bits of the Control byte contain the control code along with chip select or additional address information, depending on the particular device. The low order bit is an internal flag indicating whether it is a read or write command and should be kept clear."

    Hope this helps.
    Regards,
    TABSoft

Similar Threads

  1. Second I2C address not responding
    By Amoque in forum mel PIC BASIC Pro
    Replies: 21
    Last Post: - 18th October 2013, 06:27
  2. Replies: 2
    Last Post: - 27th August 2013, 22:07
  3. How to find I2C Slave address of PIC24FJ256GA110?
    By sharath12 in forum Off Topic
    Replies: 2
    Last Post: - 19th March 2012, 14:21
  4. 4 bit address decoding I2C chip
    By ecoli-557 in forum General
    Replies: 3
    Last Post: - 10th June 2008, 17:26
  5. quick question
    By Srigopal007 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd December 2004, 01:45

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