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.

MSP432P401R: How to use the clock low time-out select feature (UCCTLO.UCBxCTLW1) to enable a timeout window in I2C communication?

Part Number: MSP432P401R

Hi:

I tried to find the way to set the clock low timeout selection in UCBxCTLW1 Register.

I cannot find it in msp432 peripheral driver library, but only the CLOCK_LOW_TIMEOUT_INTERRUPT enable flag. How can I to set it up? thanks.

-Philip

  • Hello,

    The interrupt feature is enabled easily via MSP432 Driver Library.

    All that is needed is to setup the interrupt via the void I2C_enableInterrupt () API which supports the clock low timeout interrupt enable.

    Refer to the Driver Library API Guide: Link: (search clock low)

    I'm looking into how to configure the actual time out window via driver lib (UCB0CTLW1.UCCLTO setting) and will update that info to this post.

    -Priya

  • Quick update, I looked through the I2C APIs themselves & while we provide a way to enable the interrupt we do not provide a way to setup the timeout interval.

    I will file a bug on this & check with our SW team.

    In the meanwhile you can still write direct register access code to make this work:

    Refer section 24.4.2 in the TRM: www.ti.com/.../slau356g.pdf

    EUSCI_B0->CTLW0 |= EUSCI_B_CTLW1_CLTO_1; // delays by 28ms, use _2 or _3 for other settings


    Please let me know if this resolves your question.
  • From the split thread:
    "I tried it, set a break point for EUSCI_B_I2C_CLOCK_LOW_TIMEOUT_INTERRUPT in EUSCIB0_IRQHandler, but nothing happen."

    Can you post a code snippet to ensure you have the interrupts enabled correctly?
    Also how are you forcing the timeout to occur?


    -Priya
  • /* DriverLib Includes */
    #include <ti/devices/msp432p4xx/driverlib/driverlib.h>

    /* Standard Includes */
    #include <stdint.h>
    #include <stdbool.h>

    /* Slave Address */
    #define SLAVE_ADDRESS_1 0x51

    /* Statics */
    static volatile uint8_t RXData[256];
    static volatile uint32_t xferIndex;
    static volatile uint32_t numOfRecBytes;

    /* I2C Master Configuration Parameter */
    const eUSCI_I2C_MasterConfig i2cConfig =
    {
    EUSCI_B_I2C_CLOCKSOURCE_SMCLK, // SMCLK Clock Source
    3000000, // SMCLK = 3MHz
    EUSCI_B_I2C_SET_DATA_RATE_100KBPS, // Desired I2C Clock of 400khz
    0, // No byte counter threshold
    EUSCI_B_I2C_NO_AUTO_STOP // No Autostop
    };

    int main(void)
    {
    uint32_t i;
    /* Disabling the Watchdog */
    MAP_WDT_A_holdTimer();
    xferIndex = 0;

    /* Select Port 1 for I2C - Set Pin 6, 7 to input Primary Module Function,
    * (UCB0SIMO/UCB0SDA, UCB0SOMI/UCB0SCL).
    */
    MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1,
    GPIO_PIN6 + GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION);

    EUSCI_B0->CTLW0 |= EUSCI_B_CTLW1_CLTO_1; // delays by 28ms, use _2 or _3 for other settings
    /* Initializing I2C Master to SMCLK at 100khz with no autostop */
    MAP_I2C_initMaster(EUSCI_B0_BASE, &i2cConfig);
    MAP_I2C_setSlaveAddress(EUSCI_B0_BASE,SLAVE_ADDRESS_1);

    /* Set in receive mode */
    MAP_I2C_setMode(EUSCI_B0_BASE, EUSCI_B_I2C_RECEIVE_MODE);

    /* Clearing interrupts for I2C and enabling the module */
    MAP_I2C_enableModule(EUSCI_B0_BASE);
    MAP_I2C_clearInterruptFlag(EUSCI_B0_BASE, EUSCI_B_I2C_RECEIVE_INTERRUPT0);

    MAP_Interrupt_enableInterrupt(INT_EUSCIB0);
    //MAP_Interrupt_enableSleepOnIsrExit();

    /* Enabling master interrupts */
    MAP_Interrupt_enableMaster();

    /* Sleeping while not in use */
    while (1)
    {
    numOfRecBytes = 4;
    MAP_I2C_setMode(EUSCI_B0_BASE, EUSCI_B_I2C_RECEIVE_MODE);
    if ( numOfRecBytes > 1)
    {
    xferIndex = 0;
    MAP_I2C_masterReceiveStart(EUSCI_B0_BASE);

    }
    else // one Byte ONLY
    if ( numOfRecBytes == 1)
    {
    xferIndex = 0;
    EUSCI_B0->CTLW0 |= EUSCI_B_CTLW0_TXSTT + EUSCI_B_CTLW0_TXSTP;
    }
    MAP_I2C_enableInterrupt(EUSCI_B0_BASE, EUSCI_B_I2C_RECEIVE_INTERRUPT0 // add more interrupt flag to handle error condition
    | EUSCI_B_I2C_NAK_INTERRUPT
    | EUSCI_B_I2C_CLOCK_LOW_TIMEOUT_INTERRUPT
    | EUSCI_B_I2C_ARBITRATIONLOST_INTERRUPT);

    for (i=0; i< 100000; i++); // long delay to check scope
    }
    }

    /******************************************************************************
    * The USCI_B0 data ISR RX vector is used to move received data from the I2C
    * master to the MSP432 memory.
    ******************************************************************************/
    void EUSCIB0_IRQHandler(void)
    {
    uint_fast16_t status;

    status = MAP_I2C_getEnabledInterruptStatus(EUSCI_B0_BASE);
    MAP_I2C_clearInterruptFlag(EUSCI_B0_BASE, status);

    /* RXIFG */
    if (status & EUSCI_B_I2C_RECEIVE_INTERRUPT0)
    {
    if ( numOfRecBytes == 1 )
    {
    RXData[xferIndex++] = UCB0RXBUF;
    } else
    if (xferIndex == (numOfRecBytes - 2))
    {
    MAP_I2C_masterReceiveMultiByteStop(EUSCI_B0_BASE);
    RXData[xferIndex++] = MAP_I2C_masterReceiveMultiByteNext(EUSCI_B0_BASE);
    }
    else if (xferIndex == (numOfRecBytes - 1))
    {
    //MAP_I2C_masterReceiveMultiByteStop(EUSCI_B0_BASE); // themis may duplicate
    MAP_I2C_disableInterrupt(EUSCI_B0_BASE, EUSCI_B_I2C_RECEIVE_INTERRUPT0);
    MAP_I2C_enableInterrupt(EUSCI_B0_BASE, EUSCI_B_I2C_STOP_INTERRUPT);
    RXData[xferIndex++] = MAP_I2C_masterReceiveMultiByteNext(EUSCI_B0_BASE);
    //RXData[xferIndex++] = MAP_I2C_masterReceiveSingle(EUSCI_B0_BASE); // MAP_I2C_masterReceiveSingleByte (full start/stop) vs MAP_I2C_masterReceiveSingle
    }
    else
    {
    RXData[xferIndex++] = MAP_I2C_masterReceiveMultiByteNext(EUSCI_B0_BASE);
    }
    }
    else if (status & EUSCI_B_I2C_STOP_INTERRUPT)
    {
    MAP_I2C_disableInterrupt(EUSCI_B0_BASE, EUSCI_B_I2C_STOP_INTERRUPT);
    } else if (status & EUSCI_B_I2C_ARBITRATIONLOST_INTERRUPT)
    {
    MAP_I2C_masterReceiveMultiByteStop(EUSCI_B0_BASE);
    MAP_I2C_disableInterrupt(EUSCI_B0_BASE, EUSCI_B_I2C_ARBITRATIONLOST_INTERRUPT);
    } else if (status & EUSCI_B_I2C_NAK_INTERRUPT)
    {
    MAP_I2C_masterReceiveMultiByteStop(EUSCI_B0_BASE);
    MAP_I2C_disableInterrupt(EUSCI_B0_BASE, EUSCI_B_I2C_NAK_INTERRUPT);
    } else if (status & EUSCI_B_I2C_CLOCK_LOW_TIMEOUT_INTERRUPT)
    {
    MAP_I2C_masterReceiveMultiByteStop(EUSCI_B0_BASE);
    MAP_I2C_disableInterrupt(EUSCI_B0_BASE, EUSCI_B_I2C_CLOCK_LOW_TIMEOUT_INTERRUPT);
    }
    }
  • At first glance, the code looks correct.

    How are you forcing the clock low timeout to occur? Is the slave holding the clock low for >28ms?

    -Priya
  • I used a jumper wire to short the clock to ground during I2C data transition.

  • Hmm that seems a little unscientific :) How are you able to time your activity with the I2C transaction?


    Is there any way you can force the slave to hold the clock low in-system?
  • Edited to add: Let me try to recreate this with your example.
    -Priya
  • Hello,

    I wanted to close this post due to lack of activity.

    I was able to verify the clock low timeout functionality with the examples attached.

    I used the following setup.

    1. One MSP432 setup as I2C master & one as slave.

    2. In the transaction the slave holds the clock line low for ~30ms (90K delay cycles at ~3MHz)

    3. The master timeout window is setup to fire at 28ms.

    4. Every read request from the master results in the slave holding the clock line low>28ms. this in turn triggers the clock low ISR and updates the timeout counter.

    5. At the end of the master code, it checks the timeout counter & if this is a number greater than zero, the Launchpad LED (P1.0) blinks. The user can also pause the debugger & view the timeout variable which should have updated to 10 (for 10 data transactions).

    This functionality is not fully available via driverlib today, so I have used some direct register accesses to implement it.

    A bug has been filed to add this functionality & you should be able to see in the next release of the MSP432 SDK (~March2018).

    Thanks,

    Priya

    i2c_master_timeout.c
    /* --COPYRIGHT--,BSD
     * Copyright (c) 2017, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     * --/COPYRIGHT--*/
    /******************************************************************************
     *  MSP432 I2C - EUSCI_B0 I2C Master TX  bytes to MSP432 Slave - Repeated Start
     *
     *  Description: This demo connects two MSP432 's via the I2C bus. The master
     *  transmits to the slave. This is the MASTER CODE. It continuously
     *  transmits an array of data and demonstrates how to implement an I2C
     *  master transmitter sending multiple bytes followed by a repeated start,
     *  followed by a read of multiple bytes.  This is a common operation for
     *  reading register values from I2C slave devices such as sensors. The
     *  transaction for the I2C that is written looks as follows:
     *
     *  _________________________________________________________
     *  |  Start   |      |  Start   |                   |       |
     *  | 0x48Addr | 0x04 | 0x48Addr |  <10 Byte Read>   | Stop  |
     *  |    W     |      |    R     |                   |       |
     *  |__________|______|__________|___________________|_______|
     *
     *  ACLK = n/a, MCLK = HSMCLK = SMCLK = BRCLK = default DCO = ~3.0MHz
     *
     *                                /|\  /|\
     *                MSP432P4111     10k  10k      MSP432P4111
     *                   slave         |    |         master
     *             -----------------   |    |   -----------------
     *            |     P1.6/UCB0SDA|<-|----+->|P1.6/UCB0SDA     |
     *            |                 |  |       |                 |
     *            |                 |  |       |                 |
     *            |     P1.7/UCB0SCL|<-+------>|P1.7/UCB0SCL     |
     *            |                 |          |                 |
     *
      *****************************************************************************/
    /* DriverLib Defines */
    #include <ti/devices/msp432p4xx/driverlib/driverlib.h>
    
    /* Standard Defines */
    #include <stdint.h>
    #include <stdbool.h>
    #include <string.h>
    
    /* Slave Address for I2C Slave */
    #define SLAVE_ADDRESS       0x48
    #define NUM_OF_REC_BYTES    10
    
    /* Variables */
    const uint8_t TXData[] = {0x04};
    static uint8_t RXData[NUM_OF_REC_BYTES];
    static volatile uint32_t xferIndex;
    static volatile bool stopSent;
    unsigned int i=0, timeout=0;
    
    /* I2C Master Configuration Parameter */
    const eUSCI_I2C_MasterConfig i2cConfig =
    {
            EUSCI_B_I2C_CLOCKSOURCE_SMCLK,          // SMCLK Clock Source
            3000000,                                // SMCLK = 3MHz
            EUSCI_B_I2C_SET_DATA_RATE_100KBPS,      // Desired I2C Clock of 100khz
            0,                                      // No byte counter threshold
            EUSCI_B_I2C_NO_AUTO_STOP                // No Autostop
    };
    
    int main(void)
    {
        /* Disabling the Watchdog  */
        MAP_WDT_A_holdTimer();
    
        /* Select Port 1 for I2C - Set Pin 6, 7 to input Primary Module Function,
         *   (UCB0SIMO/UCB0SDA, UCB0SOMI/UCB0SCL).
         */
        MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1,
                GPIO_PIN6 + GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION);
        stopSent = false;
        memset(RXData, 0x00, NUM_OF_REC_BYTES);
    
        /* Initializing I2C Master to SMCLK at 100khz with no autostop */
        MAP_I2C_initMaster(EUSCI_B0_BASE, &i2cConfig);
        // Add clock low timeout , interrupt triggered if slave hold SCL>28ms
        EUSCI_B0->CTLW0 |= EUSCI_A_CTLW0_SWRST;
        EUSCI_B0->CTLW1 |= EUSCI_B_CTLW1_CLTO0;
        EUSCI_B0->CTLW0 &= ~EUSCI_A_CTLW0_SWRST;
    
        /* Specify slave address */
        MAP_I2C_setSlaveAddress(EUSCI_B0_BASE, SLAVE_ADDRESS);
    
        /* Enable I2C Module to start operations */
        MAP_I2C_enableModule(EUSCI_B0_BASE);
        MAP_Interrupt_enableInterrupt(INT_EUSCIB0);
    
        /* Making sure the last transaction has been completely sent out */
        while (MAP_I2C_masterIsStopSent(EUSCI_B0_BASE));
    
        MAP_Interrupt_enableSleepOnIsrExit();
    
        /* Send start and the first byte of the transmit buffer. */
        MAP_I2C_masterSendMultiByteStart(EUSCI_B0_BASE, TXData[0]);
    
        /* Sent the first byte, now we need to initiate the read */
        xferIndex = 0;
        MAP_I2C_masterReceiveStart(EUSCI_B0_BASE);
        MAP_I2C_enableInterrupt(EUSCI_B0_BASE, EUSCI_B_I2C_RECEIVE_INTERRUPT0);
        // Added line to enable clock low timeout interrupt
        MAP_I2C_enableInterrupt(EUSCI_B0_BASE, EUSCI_B_I2C_CLOCK_LOW_TIMEOUT_INTERRUPT);
        MAP_PCM_gotoLPM0InterruptSafe();
    
        P1->DIR |= BIT0;                        // P1.0 set as output
        P1->OUT &= ~BIT0;
    
        while (1)                               // continuous loop
        {
            if(timeout)
                P1->OUT ^= BIT0;                // Blink P1.0 LED
    
            for (i = 20000; i > 0; i--);        // Delay
        }
    }
    
    /*******************************************************************************
     * eUSCIB0 ISR. The repeated start and transmit/receive operations happen
     * within this ISR.
     *******************************************************************************/
    void EUSCIB0_IRQHandler(void)
    {
        uint_fast16_t status;
    
        status = MAP_I2C_getEnabledInterruptStatus(EUSCI_B0_BASE);
        MAP_I2C_clearInterruptFlag(EUSCI_B0_BASE, status);
        // check for clock low timeout and blink LED, update timeoutcounter
        if (status & EUSCI_B_I2C_CLOCK_LOW_TIMEOUT_INTERRUPT)
        {
            //increment timeout counter
            timeout++;
        }
    
        /* Receives bytes into the receive buffer. If we have received all bytes,
         * send a STOP condition */
        if (status & EUSCI_B_I2C_RECEIVE_INTERRUPT0)
        {
            if (xferIndex == NUM_OF_REC_BYTES - 2)
            {
                MAP_I2C_disableInterrupt(EUSCI_B0_BASE,
                        EUSCI_B_I2C_RECEIVE_INTERRUPT0);
                MAP_I2C_enableInterrupt(EUSCI_B0_BASE, EUSCI_B_I2C_STOP_INTERRUPT);
    
                /*
                 * Switch order so that stop is being set during reception of last
                 * byte read byte so that next byte can be read.
                 */
                MAP_I2C_masterReceiveMultiByteStop(EUSCI_B0_BASE);
                RXData[xferIndex++] = MAP_I2C_masterReceiveMultiByteNext(
                        EUSCI_B0_BASE);
            } else
            {
                RXData[xferIndex++] = MAP_I2C_masterReceiveMultiByteNext(
                EUSCI_B0_BASE);
            }
        }
        else if (status & EUSCI_B_I2C_STOP_INTERRUPT)
        {
            MAP_Interrupt_disableSleepOnIsrExit();
            MAP_I2C_disableInterrupt(EUSCI_B0_BASE,
                                     EUSCI_B_I2C_STOP_INTERRUPT);
        }
    }
    

    i2c_slave_forcedtimeout.c
    /* --COPYRIGHT--,BSD,BSD
     * Copyright (c) 2017, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     * --/COPYRIGHT--*/
    /******************************************************************************
     *  MSP432 I2C - EUSCI_B0 I2C Master TX  bytes to MSP432 Slave - Repeated Start
     *
     *  Description: This demo connects two MSP432 's via the I2C bus. The master
     *  transmits to the slave. This is the MASTER CODE. It continuously
     *  transmits an array of data and demonstrates how to implement an I2C
     *  master transmitter sending multiple bytes followed by a repeated start,
     *  followed by a read of multiple bytes.  This is a common operation for
     *  reading register values from I2C slave devices such as sensors. The
     *  transaction for the I2C that is written looks as follows:
     *
     *  _________________________________________________________
     *  |  Start   |      |  Start   |                   |       |
     *  | 0x48Addr | 0x04 | 0x48Addr |  <10 Byte Read>   | Stop  |
     *  |    W     |      |    R     |                   |       |
     *  |__________|______|__________|___________________|_______|
     *
     *  ACLK = n/a, MCLK = HSMCLK = SMCLK = BRCLK = default DCO = ~3.0MHz
     *
     *                                /|\  /|\
     *                MSP432P4111     10k  10k      MSP432P4111
     *                   slave         |    |         master
     *             -----------------   |    |   -----------------
     *            |     P1.6/UCB0SDA|<-|----+->|P1.6/UCB0SDA     |
     *            |                 |  |       |                 |
     *            |                 |  |       |                 |
     *            |     P1.7/UCB0SCL|<-+------>|P1.7/UCB0SCL     |
     *            |                 |          |                 |
     *
     *****************************************************************************/
    /* DriverLib Includes */
    #include <ti/devices/msp432p4xx/driverlib/driverlib.h>
    
    /* Standard Defines */
    #include <stdint.h>
    #include <stdbool.h>
    #include <string.h>
    
    /* Application Defines */
    #define SLAVE_ADDRESS       0x48
    #define NUM_OF_RX_BYTES        1
    #define NUM_OF_TX_BYTES        10
    
    /* Application Variables */
    static volatile uint8_t RXData[NUM_OF_RX_BYTES];
    static volatile uint32_t xferIndex;
    const uint32_t TXData[NUM_OF_TX_BYTES] =
    {
         0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99
    };
    
    int main(void)
    {
        /* Disabling the Watchdog  */
        MAP_WDT_A_holdTimer();
        xferIndex = 0;
    
        /* Select Port 1 for I2C - Set Pin 6, 7 to input Primary Module Function,
         *   (UCB0SIMO/UCB0SDA, UCB0SOMI/UCB0SCL).
         */
        MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1,
                GPIO_PIN6 + GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION);
    
        /* eUSCI I2C Slave Configuration */
        MAP_I2C_initSlave(EUSCI_B0_BASE, SLAVE_ADDRESS, EUSCI_B_I2C_OWN_ADDRESS_OFFSET0,
                EUSCI_B_I2C_OWN_ADDRESS_ENABLE);
    
        /* Enable the module and enable interrupts */
        MAP_I2C_enableModule(EUSCI_B0_BASE);
        MAP_I2C_clearInterruptFlag(EUSCI_B0_BASE, EUSCI_B_I2C_RECEIVE_INTERRUPT0);
        MAP_I2C_enableInterrupt(EUSCI_B0_BASE, EUSCI_B_I2C_RECEIVE_INTERRUPT0);
        MAP_Interrupt_enableInterrupt(INT_EUSCIB0);
        MAP_Interrupt_enableSleepOnIsrExit();
        MAP_Interrupt_enableMaster();
    
        /* Sleeping while not in use */
        while (1)
        {
            MAP_PCM_gotoLPM0();
        }
    }
    
    /*******************************************************************************
     * eUSCIB0 ISR. The repeated start and transmit/receive operations happen
     * within this ISR.
     ******************************************************************************/
    void EUSCIB0_IRQHandler(void)
    {
        uint_fast16_t status;
    
        status = MAP_I2C_getEnabledInterruptStatus(EUSCI_B0_BASE);
        MAP_I2C_clearInterruptFlag(EUSCI_B0_BASE, status);
    
        /* RXIFG */
        if (status & EUSCI_B_I2C_RECEIVE_INTERRUPT0)
        {
            RXData[xferIndex++] = MAP_I2C_slaveGetData(EUSCI_B0_BASE);
    
            /* Resetting the index if we are at the end */
            if (xferIndex == NUM_OF_RX_BYTES)
            {
                xferIndex = 0;
                MAP_I2C_disableInterrupt(EUSCI_B0_BASE,
                                         EUSCI_B_I2C_RECEIVE_INTERRUPT0);
                MAP_I2C_enableInterrupt(EUSCI_B0_BASE,
                                        EUSCI_B_I2C_TRANSMIT_INTERRUPT0);
            }
        }
    
        /* TXIFG */
        if (status & EUSCI_B_I2C_TRANSMIT_INTERRUPT0)
        {
            __delay_cycles(90000);
            MAP_I2C_slavePutData(EUSCI_B0_BASE, TXData[xferIndex++]);
    
            /* Resetting the index if we are at the end */
            if (xferIndex == NUM_OF_TX_BYTES)
            {
                xferIndex = 0;
                MAP_I2C_disableInterrupt(EUSCI_B0_BASE,
                                         EUSCI_B_I2C_TRANSMIT_INTERRUPT0);
                MAP_I2C_enableInterrupt(EUSCI_B0_BASE,
                                        EUSCI_B_I2C_RECEIVE_INTERRUPT0);
            }
        }
    }
    

**Attention** This is a public forum