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.

MSP430FR2433: I2C as a slave is not working

Part Number: MSP430FR2433
Other Parts Discussed in Thread: CC2642R

Hi,

i using EXP430FR2433 developement kit , i configured MSP430FR2433 as a slave and configured p1.2 as SDA and p1.3 as SCL and also i enabled the I2C interrupt to receive the data from master.......but I2C interrupt is not triggering even once also to receive the data. while connecting the SDA and SCL pin with master, the MSP430 EVK is pulling down the SDA line ....can you give a solution for this..?

In master side i receiving the error like "I2C bus is already in use"

The slave mode configuration in MSP430FR2433 code is below 

/*----------------------------------------GPIO Config----------------------------------------*/

void GPIO_Config()

{

GPIO_setAsPeripheralModuleFunctionInputPin(
GPIO_PORT_P1,
MSP_I2C_SDA | MSP_I2C_SCL,
GPIO_PRIMARY_MODULE_FUNCTION
);

PM5CTL0 &= ~LOCKLPM5;

}

/*----------------------------------------Salve mode----------------------------------------*/

void set_i2c_slave_mode ()
{
param_i2c_slave .slaveAddress = SLAVE_ADDRESS;   //SLAVE_ADDRESS = 0x44
param_i2c_slave .slaveAddressOffset = EUSCI_B_I2C_OWN_ADDRESS_OFFSET0;  // EUSCI_B_I2C_OWN_ADDRESS_OFFSET0 = 0x00
param_i2c_slave .slaveOwnAddressEnable = EUSCI_B_I2C_OWN_ADDRESS_ENABLE; // EUSCI_B_I2C_OWN_ADDRESS_ENABLE = UCOAEN
EUSCI_B_I2C_initSlave_registers(EUSCI_B0_BASE, &param_i2c_slave );

//Enable I2C Module to start operations
EUSCI_B_I2C_enable(EUSCI_B0_BASE);

EUSCI_B_I2C_clearInterrupt(EUSCI_B0_BASE,
EUSCI_B_I2C_TRANSMIT_INTERRUPT0 |
EUSCI_B_I2C_RECEIVE_INTERRUPT0 |
EUSCI_B_I2C_CLOCK_LOW_TIMEOUT_INTERRUPT |
EUSCI_B_I2C_STOP_INTERRUPT
);

EUSCI_B_I2C_enableInterrupt(EUSCI_B0_BASE,
EUSCI_B_I2C_RECEIVE_INTERRUPT0 |
EUSCI_B_I2C_CLOCK_LOW_TIMEOUT_INTERRUPT |
EUSCI_B_I2C_STOP_INTERRUPT
);

UCB0CTLW1 |= UCCLTO_3; //(clk low timeout for approximately 34 ms)

}

/*----------------------------------------Interrupt----------------------------------------*/

#pragma vector=USCI_B0_VECTOR

__interrupt void USCIB0_ISR(void) // All Interrupts disabled inside ISR

{

}

  • Could you a logic analyzer to capture the waves? Like saleae

    Recommend to use this demo code https://dev.ti.com/tirex/explore/node?node=ACgjYchX9i5RkshXLLcisA__IOGqZri__LATEST 

    You can modify this demo code based on your application.

  • No this code i already tried it was not working , still MSP430 is pulling down the SDA . can you give some other solutions??

  • The demo code should be working that we have been verified many times. What's the host side? Why do you so confirm this issue is related with MSP430 not he host device?

  • No it is not working , Here CC2642R TI controller is master and MSP4302433 TI controller is slave ....... we are transmitting 1 byte data to slave but

    In slave side code I2C interuppt is not calling .....

    #pragma vector = USCI_B0_VECTOR

    __interrupt void USCI_B0_ISR(void)

    {

    }

    In master side we are receiving the error as "I2C slave address 0x48 not acknowledged!"........

    MASTER I2C configuration code:

    /* Create I2C for usage */
    I2C_Params_init(&i2cParams);
    i2cParams.bitRate = I2C_100kHz;
    i2c = I2C_open(CONFIG_I2C_TMP, &i2cParams);
    if (i2c == NULL) {
    Display_printf(display, 0, 0, "Error Initializing I2C\n");
    while (1);
    }
    else {
    Display_printf(display, 0, 0, "I2C Initialized!\n");
    }

    /* Common I2C transaction setup */
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 1;
    i2cTransaction.readBuf = rxBuffer;
    i2cTransaction.readCount = 0;

    i2cTransaction.slaveAddress = 0x48;
    txBuffer[0] = 0x03;

    while(1)
    {

    if (I2C_transfer(i2c, &i2cTransaction)) {

    Display_printf(display, 0, 0, "Detected with slave address ");
    }
    else {
    i2cErrorHandler(&i2cTransaction, display);
    }

    sleep(1);
    }

    /* Sleep for 1 second */
    sleep(1);


    I2C_close(i2c);

    SLAVE I2C configuration code :

    void initI2C()
    {
    UCB0CTLW0 = UCSWRST; // Software reset enabled
    UCB0CTLW0 |= UCMODE_3 | UCSYNC; // I2C mode, sync mode
    UCB0I2COA0 = SLAVE_ADDR | UCOAEN; // Own Address and enable
    UCB0CTLW0 &= ~UCSWRST; // clear reset register
    UCB0IE |= UCRXIE + UCSTPIE;

  • There must some thing wrong on your side. Do you use the demo code that without any code change? If you changed please show me where you changed.

    Please help to capture the wave of SCL and SDA when you do the test.

  • I did'nt changed anything on the slave code ....according to the slave code i changed slave address and register address in master code.

    but the I2C interrupt call  which is mentioned below is not calling in MSP side .....

    #pragma vector = USCI_B0_VECTOR

    __interrupt void USCI_B0_ISR(void)

    {

    }

    and In main function i enabled the interupt as below

    __bis_SR_register(LPM0_bits + GIE);

  • and also i tried the MSP430 controller as master also In that while writing as per below function..... It is blocking at "__bis_SR_register(LPM0_bits + GIE); "  this line.... 

    I2C_Mode I2C_Master_WriteReg(uint8_t dev_addr, uint8_t reg_addr, uint8_t *reg_data, uint8_t count)
    {
    /* Initialize state machine */
    MasterMode = TX_REG_ADDRESS_MODE;
    TransmitRegAddr = reg_addr;

    //Copy register data to TransmitBuffer
    CopyArray(reg_data, TransmitBuffer, count);

    TXByteCtr = count;
    RXByteCtr = 0;
    ReceiveIndex = 0;
    TransmitIndex = 0;

    /* Initialize slave address and interrupts */
    UCB0I2CSA = dev_addr;
    UCB0IFG &= ~(UCTXIFG + UCRXIFG); // Clear any pending interrupts
    UCB0IE &= ~UCRXIE; // Disable RX interrupt
    UCB0IE |= UCTXIE; // Enable TX interrupt

    UCB0CTLW0 |= UCTR + UCTXSTT; // I2C TX, start condition
    __bis_SR_register(LPM0_bits + GIE); // Enter LPM0 w/ interrupts     --------->Blocked here 

    return MasterMode;
    }

    Here also while transmitting the data below mentioned interrupt handler is not calling ...

    #pragma vector = USCI_B0_VECTOR


    __interrupt void USCI_B0_ISR(void)

    {

    }

  • Hi I have test the demo code with no problem. I use FR2355 launchpad as host and FR2433 launchpad as slave it works well. I use a logic analyzer Saleae to capture the waves as below

    Session 0.sal

    Could you capture some waves here?

**Attention** This is a public forum