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: Could not generate clock for I2C communication

Part Number: MSP432P401R

Hello,

I am trying to establish communication between 2 MSP432P401R's using an example code(i2c_master_rw_repeated_start-master_code), but I am not able to generate clock. I debugged the code, the sequence is not entering the EUSCIB0_IRQHandler. 


Could you kindly let me know what would be the problem. 

Thanks,

Sushrut

  • Hello,
    Do you have pullups on the I2C lines? Have you downloaded the corresponding slave code on the other device? Can you try another pair of i2c example code?

    dev.ti.com/.../

    dev.ti.com/.../

    Thanks and Regards,
    Chris
  • Hello Chris,

    Thank you for your reply.

    It is working now, i had forgotten to connect pull up resistors.

    But I am interfacing an external temperature and humidity sensor to MSP432. I am using master code for MSP432. But i have Arduino files for this sensor. Can i get any files for this sensor which is compatible to MSP432.

    I am using CCS for this.

    I am not able to establish communication between MSP432 and sensor,  any example code that you would suggest to interface external sensors like this.

    Thanks,

    Sushrut

  • Sushrut,
    Looking at the datasheet it looks like a repeated start example would work well. dev.ti.com/.../

    You would need to adjust the size of the tx to send the command msb and lsb and then the recieve would just be 6 bytes. There also appears to be some commands that do not have a read that follows so you can use the multibyte master code to send the two bytes.

    Chris
  • Hi Chris,

    Thank you for your reply.

    I tried with the repeated start example code.

    I have changed the msb and lsb of the tx array in the code. But I am not getting any data from the sensor. The cod sequence is entering into the

    if (status & EUSCI_B_I2C_TRANSMIT_INTERRUPT0), but it is not entering the if (status & EUSCI_B_I2C_RECEIVE_INTERRUPT0).

    Also i did not understand why do i need to use the multi byte master code to send two bytes.

    Could you kindly look into it and let me know what i have missed.i2c_master_rw_repeated_start-master_code_MSP_EXP432P401R_nortos_ccs.rar

    Thanks,

    Sushrut

  • Hi Chris,

    I have added header files of the sensor and made changes in the code to receive data from it, but I not able to get data from sensor.

    I am not using any IRQHandler, I am just using  simple commands to read data.

    Could you kindly look into the attached code and help me out to read the data.

    i2c_slave_initiated_read-master_code_Techchallenge.rar

    Thanks,

    Sushrut

  • Hi Chris,

    I am using repeated start master code.

    I debugged the code line by line to check why the MSP is not communicating with sensor.

    I came to know that the code execution is stopping in MAP_I2C_masterSendMultiByteStart command. I went deeper into the function, then the below while loop is not executing. 

    //Poll for transmit interrupt flag.
    while (!BITBAND_PERI(EUSCI_B_CMSIS(moduleInstance)->rIFG.r, UCTXIFG_OFS));

    Basically i am not able to send the start byte to sensor.

    Could you kindly help me out with this?

    Thanks,

    Sushrut

  • Sushrut,
    I looked at the code that you sent and I am unable to find the relevant I2C commands. Maybe this example might help:

    dev.ti.com/.../

    Specficially, refer to the i2c_driver.c (starting at line 177 and 350) and how the tmp007.c is accessed.

    /***********************************************************
    Function:
    */
    bool readI2C(uint8_t ui8Addr, uint8_t ui8Reg, uint8_t *Data, uint8_t ui8ByteCount)
    {
    /* Todo: Put a delay */
    /* Wait until ready */
    while (MAP_I2C_isBusBusy(EUSCI_B1_BASE));

    /* Assign Data to local Pointer */
    pData = Data;

    /* Disable I2C module to make changes */
    MAP_I2C_disableModule(EUSCI_B1_BASE);

    /* Setup the number of bytes to receive */
    i2cConfig.byteCounterThreshold = ui8ByteCount;
    i2cConfig.autoSTOPGeneration = EUSCI_B_I2C_SEND_STOP_AUTOMATICALLY_ON_BYTECOUNT_THRESHOLD;
    MAP_I2C_initMaster(EUSCI_B1_BASE, (const eUSCI_I2C_MasterConfig *)&i2cConfig);

    /* Load device slave address */
    MAP_I2C_setSlaveAddress(EUSCI_B1_BASE, ui8Addr);

    /* Enable I2C Module to start operations */
    MAP_I2C_enableModule(EUSCI_B1_BASE);

    /* Enable master STOP and NACK interrupts */
    MAP_I2C_enableInterrupt(EUSCI_B1_BASE, EUSCI_B_I2C_STOP_INTERRUPT +
    EUSCI_B_I2C_NAK_INTERRUPT);

    /* Set our local state to Busy */
    ui8Status = eUSCI_BUSY;

    /* Send start bit and register */
    MAP_I2C_masterSendMultiByteStart(EUSCI_B1_BASE,ui8Reg);

    /* Enable master interrupt for the remaining data */
    MAP_Interrupt_enableInterrupt(INT_EUSCIB1);

    /* NOTE: If the number of bytes to receive = 1, then as target register is being shifted
    * out during the write phase, UCBxTBCNT will be counted and will trigger STOP bit prematurely
    * If count is > 1, wait for the next TXBUF empty interrupt (just after reg value has been
    * shifted out
    */
    while(ui8Status == eUSCI_BUSY)
    {
    if(MAP_I2C_getInterruptStatus(EUSCI_B1_BASE, EUSCI_B_I2C_TRANSMIT_INTERRUPT0))
    {
    ui8Status = eUSCI_IDLE;
    }
    }

    ui8Status = eUSCI_BUSY;

    /* Turn off TX and generate RE-Start */
    MAP_I2C_masterReceiveStart(EUSCI_B1_BASE);

    /* Enable RX interrupt */
    MAP_I2C_enableInterrupt(EUSCI_B1_BASE, EUSCI_B_I2C_RECEIVE_INTERRUPT0);

    /* Wait for all data be received */
    while(ui8Status == eUSCI_BUSY)
    {

    #ifdef USE_LPM
    MAP_PCM_gotoLPM0();
    #else
    __no_operation();
    #endif
    }

    /* Disable interrupts */
    MAP_I2C_disableInterrupt(EUSCI_B1_BASE, EUSCI_B_I2C_STOP_INTERRUPT +
    EUSCI_B_I2C_NAK_INTERRUPT + EUSCI_B_I2C_RECEIVE_INTERRUPT0);
    MAP_Interrupt_disableInterrupt(INT_EUSCIB1);

    if(ui8Status == eUSCI_NACK)
    {
    return(false);
    }
    else
    {
    return(true);
    }
    }

    Regards,
    Chris

**Attention** This is a public forum