This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

msp430f6659

hi

I want to use I2C USI for communication between msp430f6659(as master) and pca9505as slave)

Please tell how will I know what the slave address is? I want to write into the registers of pca9505as .

Is the register address same as the slave address?

thanks

  • Hi Lalitha,

    The I2C slave address is used in I2C communication so that you could potentially have 1 master device communicate with multiple slave devices all on the same line. Having unique slave addresses for each slave in the system lets the master specify a particular slave that it wants to send a message to, telling other slaves listening on the same line to ignore this message.

    Most I2C slave devices like the one that you mentioned have a way for you to assign it one of a few different slave addresses so that you could have multiple of these slaves in your system without conflict. If you look in the datasheet of your slave device, there is a section discussing how to set the address of the device. It looks like for this device there are some bits that are always fixed or the same, but there are 3 bits that you can set by having the pins on the device be connected to either Vcc or GND to set the bits to 0 or 1. So at startup that device must be checking its pins to set its own slave address.

    So connect the slave address pins on your slave however you'd like, and determine the corresponding slave address. For example, if you pulled the pins all low your slave address might be 0100000b or 0x20. Then in your MSP430 I2C master code, you will want to set the USCI slave address register to match this.

    lalitha p said:

    I want to write into the registers of pca9505as .

    Is the register address same as the slave address?

    For addressing particular registers in your slave device, you still need the slave address set in your MSP430 code (it will automatically use this slave address in all transmissions then), but your slave device likely has a protocol layer that it needs you to implement on top of the I2C. Typically the slave device datasheet will define a command format and set of commands for you to use, along with register addresses, in order to access the different registers. You'll basically need to implement some sort of driver/higher-level protocol for controlling and accessing the slave device. For help with that protocol, you may need to look more into the documentation and support from your slave device's manufacturer as they will be familiar with how that protocol should be defined for talking to their device.

    Regards,

    Katie

  • An I2C transfer consists of an start condition followed by an address byte and several data bytes and is ended by a stop condition or another start condition (a 'repeated start') and a second transfer. The address byte contains the 7 bit slave address and a R/W flag to indicate the transfer direction. The slave address is (as Katie explained) found in the slave datasheet. Note that the slave address you need is the same for read and write, so if the datasheet lists two different addresses for read and write, you need to shift this value right by one bit (taking only the upper 7 bits as slave address, right-justified).

    On many slaves that have registers, the second byte sent by the master (in write mode) is interpreted as register address. Subsequent writes write to this register and the following ones. If you start a read transfer right after writing the register address, the specified register is read (and after it the following ones, incrementing the register number with each read).
    However, this kind of protocol is slave-specific. And while this is a common case, you specific slave may do things differently. Again the slave datasheet tells you how to do it.

    I2C only specifies how to send/receive one or more byte(s) to/from a slave with a certain slave address. It does not specify by any means what these bytes mean to the slave.

**Attention** This is a public forum