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.

MSP430FR5994: I2C interface to LDC1312

Part Number: MSP430FR5994
Other Parts Discussed in Thread: LDC1312,

Hello everyone in MSP430 land,

I have a project on a custom board. I’m using an MSP430FR5994 with an LDC1312 (inductance to digital converter) on an I2C bus (actually there are four LDCs, each on its own I2C interface). It is the only device on the bus. The MSP430 is the Master.

In the past, I have successfully “bare metal’d” such code, but this time I decided to use the MSP430 Driverlub. I believe I’m now accessing the LDC registers to configure the device (Write to registers, but having a considerable amount of trouble reading the registers. When reading the registers, the Driverlib returns 0. However, accessing the registers from CCS, UCBxRXBUF (x= 0, for this interface), there’s other than 0 in the memory-mapped register. I scope’d the I2C bus and it looks like data is coming across the interface that matches the MSP430 Receive Buffer; however, as stated the Driverlib only returns 0.

This read interface to the LDC requires a “I2C Restart.” Not sure if I’m doing it correctly using the Driverlib. (The setMode statements don’t seem to make any differences

The I2C interface of the MSP430 is initialized elsewhere as well as configuring the LDC Registers.

I’ve tried many different code attempts, including reading the register directly after the Driverlib receive request with no difference. Out of options. What do you think?

The LDC is at I2C address 0x2A. The Data Read is 0.
BaseAddress = 0x0640 (I2C Interface b0), LDC1312Register = 0

Simple code:

    uint8_t RxMSB, RxLSB;

    EUSCI_B_I2C_setMode (BASEADDRESS_I2C2, EUSCI_B_I2C_TRANSMIT_MODE);

    EUSCI_B_I2C_masterSendMultiByteStart (BaseAddresss,LDC1312Register);    // sends Slave Address on I2C Bus provided by "setSlaveAddress()"
    EUSCI_B_I2C_masterSendMultiByteFinish (BaseAddresss, LDC1312Register);

    EUSCI_B_I2C_setMode (BASEADDRESS_I2C2, EUSCI_B_I2C_RECEIVE_MODE);

    EUSCI_B_I2C_masterReceiveStart(BaseAddresss);        // sends Slave Address on I2C Bus
    RxMSB = EUSCI_B_I2C_masterReceiveMultiByteNext(BaseAddresss);
    RxLSB = EUSCI_B_I2C_masterReceiveMultiByteFinish (BaseAddresss);

I’ve tried a couple different ways to read the Receive Buffer, but it is always 0.

I am including scope screenshot.

  • Looking at data sheet (SNOSCZ0A) Table 14, register 0 is DATA0, which I think is =0000 until you do something to start the device. Maybe register 0x7E (MANUFACTURER_ID) would be a better test case?

    You're correct that the masterSendXX and masterReceiveXX functions set UCTR appropriately, so setMode is superfluous.

    To get a repeated-start, leave out the call to EUSCI_B_I2C_masterSendMultiByteFinish() [which I think you don't want anyway since I think it tries to write register DATA0=0]. That said, from reading the data sheet I'm not sure the device Really Needs a repeated-start, even if it says so; EUSCI_B_I2C_masterSendSingleByte() [start/write/stop] might suffice to set the register number.

  • Sorry, I missed this before:

       RxMSB = EUSCI_B_I2C_masterReceiveMultiByteNext(BaseAddresss);

    Looking at the source, ReceiveMultiByteNext() doesn't gate on RXIFG, rather it just fetches RXBUF. To gate on RXIFG, you need

       RxMSB = EUSCI_B_I2C_masterReceiveSingle(BaseAddresss);

    ReceiveMultiByteFinish() does gate on RXIFG, but by then you're already off-by-1.

  • Thank you Bruce for the quick response. I tried your suggestion and it did work. I guess one would use "ReceiveNext" if one were to use interrupts. Also tried your suggestion to get the DeviceID and that did work.

**Attention** This is a public forum