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.

MSP430FR5739: Driverlib I2C Example Question

Part Number: MSP430FR5739
Other Parts Discussed in Thread: FDC1004

Hi, 

Apologies if this has been asked on here before but I couldn't find a specific answer.

Firstly, I am new to MSP430, I've only previously worked with ST Arm MPUs for about 6 months. 

I am trying to use I2C to communicate with the FDC1004 capacitance sensing chip. I have been looking at the Driverlib examples, and there is one thing that doesn't seem to make an sense to me.

In the examples, TX functions have a parameter, like the following filled with  "transmitData". Initially I thought this was the data that you want to send to the slave. The problem is then, how do you specify what address to write to in the slaves registry?

EUSCI_B_I2C_masterSendSingleByte(EUSCI_B0_BASE, transmitData); 

For reference, this is the inside of that function

void EUSCI_B_I2C_masterSendSingleByte (uint16_t baseAddress,
    uint8_t txData
    )
{
    //Store current TXIE status
    uint16_t txieStatus = HWREG16(baseAddress + OFS_UCBxIE) & UCTXIE;

    //Disable transmit interrupt enable
    HWREG16(baseAddress + OFS_UCBxIE) &= ~(UCTXIE);

    //Send start condition.
    HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCTR + UCTXSTT;

    //Poll for transmit interrupt flag.
    while (!(HWREG16(baseAddress + OFS_UCBxIFG) & UCTXIFG)) ;

    //Send single byte data.
    HWREG16(baseAddress + OFS_UCBxTXBUF) = txData;

    //Poll for transmit interrupt flag.
    while (!(HWREG16(baseAddress + OFS_UCBxIFG) & UCTXIFG)) ;

    //Send stop condition.
    HWREG16(baseAddress + OFS_UCBxCTLW0) |= UCTXSTP;

    //Clear transmit interrupt flag before enabling interrupt again
    HWREG16(baseAddress + OFS_UCBxIFG) &= ~(UCTXIFG);

    //Reinstate transmit interrupt enable
    HWREG16(baseAddress + OFS_UCBxIE) |= txieStatus;
}

According to another question on here, it seemed like in the example, transmitData is set at 0x01 and is actually the pointer to the register to write to. However, if this is the case, then what is the data that is sent to it?

Apologies if this is a stupid question. Maybe I am lacking understanding of I2C. 

Thanks, 

Damien

  • Hello Damien,

    Thanks for your detailed post and for using the Syntaxhighlighter - it always makes reading code much easier!

    If I understand the 'eusci_b_i2c_ex4_masterTxSingle.c' code example, it's just demonstrating how to send over one data byte from the I2C master to the I2C slave. Obviously, it sends over the defined slave address first. What the I2C slave does with this data byte probably depends on the slave device.

    Now, looking at Section 8.5.2 in the FDC1004's datasheet, you're right that the FDC1004 is expecting the first byte transferred after the slave address byte with the R/W bit low to be the pointer value. After this, you'd want to send the MSB and LSB data for that register. David's post in the following thread gives some context for why the description in the datasheet seems limited.

    FDC1004 i2c communication

    Are you required to use the FDC1004? Have you considered using one of our MSP430 FRAM CapTIvate devices that support capacitive touch and can be used with the CapTIvate Design Center?

    MSP430™ capacitive touch sensing microcontrollers

    CapTIvate™ Design Center GUI for MSP430™ Capacitive Sensing MCUs

    MSP430 Capacitive Touch MCUs featuring CapTIvate™ Technology Training Series

    Regards,

    James

  • Hi James, thank you for your quick reply.

    I think you can tell it was a Friday afternoon when I wrote this, after a long week of work. I totally misunderstood that it was sending a single byte, not 4 bytes.

    I'm currently redesigning a capacitive sensor, the original used the FDC so we had the EVM board,and so I decided to start with that.

    It's the first time I've used a TI Micro, so it's been a steep learning curve the last week. I actually managed to get some readings from the chip by the end of Friday.

    Thanks for your reply,

    Damien

**Attention** This is a public forum