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.

MSP430FR5992: I2C read byte from sensor with address and sub-address (LIS3DH)

Part Number: MSP430FR5992

Dear all,
I’m trying to implement an I2C sensor (LIS3DH) into my program for an MSP420FR599x via the eUSCI_B0. Sadly after reading the Family data sheet I’m more confused how to set it up than before – but I’m hopeful you are able to help me. The problem is surely an easy one for someone proficient with the I2C protocol and/or the MSP…. neither am I ;) .

The sensor defines the communication as the following (p.26 DS):
START -- slave-address+write-bit -- wait AK -- send 8bit sub address – wait AK – reapeated START - slave-address+read-bit -- wait AK -- get 8bit data -- no master acknowledge -- STOP
So the MSP needs to send a sub address / command as the first “databyte” and after the AK the MSP should perform a repeated start followed by a read prosses to the slave-address.
I’m at a loss how to initialize the i2c usci for this case and how to perform this transmission with a follow up read out… is it even possible or do I need to do it all “manually” via software?

Currently I initialize the usci via:
    UCB0CTLW0 = UCSWRST;    // reset state
    UCB0CTLW0 |= UCMODE_3 | UCMST | UCSLA10_0 | UCTXSTT;  // I2C | master mode | SLADD 7bit | repeated start
    UCB0CTLW0 |= UCSSEL_2; //SMCLK
    UCB0BRW = 20;   //MCLK = 2MHz -> baud rate: MCLK / 20 = 100kHz
    UCB0CTLW1 = UCASTP_0;   // no STOP assertion
    UCB0TBCNT = 1;   // 1 bytes of data
    UCB0CTLW0 &= ~UCSWRST;

In a read byte function I would set up the slave address (CSA) and if I want to transmit or receive… do I need to set the read/write bit manually with a bitmask into the slave address or does it get added automatically via the UCTR? I would then send the sub address as a transmission and after getting the AK I would start a receiving?!?
Is it the correct way to handle this, or am I missing a functionality which is hardware implemented?

I would really appreciate an small example, the TI examples are a bit too simple or do too much at once.

Best wishes and thank you for your help
Tobias

  • There is nothing unusual about this device except for the way the transaction is described. The sub address is just a device register address and thousands of parts do this.

    The I2C interface is tricky to deal with. Look at the TI code examples for this device for examples of how to do it. The LIS3DH also does SPI which is a lot simpler to use.

**Attention** This is a public forum