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: EUSCI_B_I2C_masterSendMultiByteFinish byte not transmitted

Part Number: MSP430FR5739

Hello,

I'm having an issue with the last byte of a MasterSend transmission not being transmitted, and I have a feeling it's with the order of calls I'm making( or not making).  I've tested this with both my I2C Slave, and with an Aardvark as I2C slave, and they both behave the same, so I'm feeling the problem lies in my master code.

The only interrupt I'm using is the EUSCI_B_I2C_NAK_INTERRUPT, as this code communicates with multiple slaves, and which can sometimes be not present.   Here is the order of calls. 

    //Specify slave address
    EUSCI_B_I2C_setSlaveAddress(EUSCI_B0_BASE, toSlaveAddress);
    //Set Master in transmit mode
    EUSCI_B_I2C_setMode(EUSCI_B0_BASE,
    EUSCI_B_I2C_TRANSMIT_MODE);

    //Enable I2C Module to start operations
    EUSCI_B_I2C_enable(EUSCI_B0_BASE);
    EUSCI_B_I2C_enableInterrupt(EUSCI_B0_BASE,EUSCI_B_I2C_NAK_INTERRUPT);
    EUSCI_B_I2C_masterSendMultiByteStart (EUSCI_B0_BASE,command[0]
        );
 

    while(!(EUSCI_B_I2C_getInterruptStatus(EUSCI_B0_BASE, EUSCI_B_I2C_TRANSMIT_INTERRUPT0))){
        if (NACKReceived == true)
        {
            NACKReceived = false;
            StopI2C();
            return;
        }
    }
    EUSCI_B_I2C_masterSendMultiByteNext(EUSCI_B0_BASE,command[1]);
    
    while(!(EUSCI_B_I2C_getInterruptStatus(EUSCI_B0_BASE, EUSCI_B_I2C_TRANSMIT_INTERRUPT0))){}
 
    EUSCI_B_I2C_masterSendMultiByteFinish(EUSCI_B0_BASE,command[2]);
 

    StopI2C();

If I add another call to EUSCI_B_I2C_masterSendMultiByteNext prior to the EUSCI_B_I2C_masterSendMultiByteFinish, that byte is transmitted, and the last byte is still not sent.

I'm fairly new to the MSP platform, but not to embedded, so feel that I'm missing something, obviously

Any thoughts appreciated

Regards

Jonny

  • Hi Jonny,

    Could you remove the polling operation and try again?

    while(!(EUSCI_B_I2C_getInterruptStatus(EUSCI_B0_BASE, EUSCI_B_I2C_TRANSMIT_INTERRUPT0))){}

  • Hi Winter,

    Thanks for your reply.

    I get the same behavior if I remove all of the while loop interrupt polling.

    I was able to resolve the problem.  After the transmission was being made, the I2C module was being shutdown.  I added a delay prior to the shutdown, to give ample time for the transmission to complete, and that solved the problem

    Regards

    Jonny

**Attention** This is a public forum