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.

MSP430FR2311: I2C Driverlib Questions



Hi I have one more question.

Actually, I'm going to use drivelib I2C function.

But it only provide single Byte send function.

this is the 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;

HWREG16(baseAddress + OFS_UCBxCTLW0) |= 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;
}



But I want to use 2 byte send function.

how can I modify that?

Could you give me some tips?

Thank you !

Bye

  • Hey Minkyo,

    I've split this as a new thread since we solved your issue in the other thread.   Also, please use the software posting tool ( </> button) to post code.  Keeps it most readable so the community can give you quicker feedback.  

    Also, there are Multi-Byte functions as well.  Please see the Driverlib API Guide for MSP430FR2xx_4xx Devices.  

    I believe the flow would go something like this:

    EUSCI_B_I2C_masterSendMultiByteStart (uint16_t baseAddress, uint8_t txData);
    
    EUSCI_B_I2C_masterSendMultiByteNext (uint16_t baseAddress, uint8_t txData);
    
    EUSCI_B_I2C_masterSendMultiByteNext (uint16_t baseAddress, uint8_t txData);
    
    EUSCI_B_I2C_masterSendMultiByteStop (uint16_t baseAddress);  

    Let me see if there are any software examples using this.  

    Thanks,

    JD

  • Hey Minkyo,

    There is a MasterTXMultiple byte driverlib example in TI Resource Explorer: dev.ti.com/.../

    It shows how to send multiple bytes and is interupt driven.

    Thanks,
    JD

**Attention** This is a public forum