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.

MSP430 I2c Communication question

Hello. I am very new to MSP430 I2C programming. I tried to follow the sample code provided. and the below code is from msp430g2x21_usi_06.c file from slac463a.zip.

I don't very understand this line below:

char SLV_Addr = 0x91;                  // Address is 0x48 << 1 bit + 1 for Read

Why address 0x48 is bit shifted to left and added one?

Can anyone please explain what is going on here?

If it is to write, then what would be the address ? 0x90?

Please help me.

Thank you!

-Jeonggoo Song

  • Hi,

     

    Reading I2C specifications you will find that data exchange begins with the master sending the “start bit”, followed by slave address (7-bits address mode), which is followed by a single bit representing whether it wishes to write(0) to or read(1) as the least meaning bit. After each byte received the slave sends the “acknowledge  bit”. Master finish data transaction sending a “stop bit”.

    Best regards,

    AES

  • As AES explaind, the address is 7 bit, left justified and filled with the R/W bit. And yes, if it were a write operation, the result would be 0x90. However, the address is still 0x48, only the byte to send is 0x90 then :)

    However, most I2C slave datasheets already give the slave address in shifted form (0x90/0x91 for write or read).
    This often causes confusion if people use the USCI module, where you have to put the unshifted address into the slave address register and the R/W bit is added when you actually start the transfer absed on a direction bit in a config register.

**Attention** This is a public forum