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.

LAUNCHXL2-TMS57012: Launchpad LAUNCHXL2-TMS57012 I2C communication

Part Number: LAUNCHXL2-TMS57012

Hello, I am trying to communicate a PCB with the launchpad LAUNCHXL2-TMS57012 through I2C. The code is simple, the launchpad has just to receive and plot what it receives; it is connecter to the PC and with Labview, I see the results. I have tried the communication with an Arduino and it works correctly. With the launchpad, I am not haveing communication. My question is, in Arduino I am using 2 pull-up resistors for the I2C communication; the launchpad seems to be yet pulled up, is it correct or should I use pull-up resistors?

The code I am using is:

/* Include Files */

#include "sys_common.h"

/* USER CODE BEGIN (1) */
#include "i2c.h"
/* USER CODE END */

/** @fn void main(void)
*   @brief Application main function
*   @note This function is empty by default.
*
*   This function is called after startup.
*   The user can use this function to implement the application.
*/

/* USER CODE BEGIN (2) */
#define DATA_COUNT  8

#define Slave_Address  0x50

//uint8_t TX_Data_Master[10] = { 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19};
//uint8_t RX_Data_Master[10] = { 0 };

//uint8_t TX_Data_Slave[10] = { 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29};
uint8_t RX_Data_Slave[8] = { 0 };

/* USER CODE END */

void main(void)
{
/* USER CODE BEGIN (3) */

    int repeat = 0;

///////////////////////////////////////////////////////////////
//        Slave Receiver Functionality                      //
///////////////////////////////////////////////////////////////
    /* I2C Init as per GUI
     *  Mode = Slave - Receiver
     *  baud rate = 100KHz
     *  Count = 10
     *  Bit Count = 8bit
     */
    i2cInit();

    /* Configure own address so that master can use it as slave address */
    i2cSetOwnAdd(i2cREG1, Slave_Address);

    /* Set direction to receiver */
    /* Note: Optional - It is done in Init */
    i2cSetDirection(i2cREG1, I2C_RECEIVER);

    for(repeat = 0; repeat < 2; repeat++)
    {

        /* Configure Data count */
        /* Note: Optional - It is done in Init, unless user want to change */
        i2cSetCount(i2cREG1, DATA_COUNT);

        /* Tranmit DATA_COUNT number of data in Polling mode */
        i2cReceive(i2cREG1, DATA_COUNT, RX_Data_Slave);

        /* Wait until Bus Busy is cleared */
        while(i2cIsBusBusy(i2cREG1) == true);

        /* Wait until Stop is detected */
        while(i2cIsStopDetected(i2cREG1) == 0);

        /* Clear the Stop condition */
        i2cClearSCD(i2cREG1);
    }
fprintf("%c", RX_Data_Slave);


    while(1);
}

Meanwhile, the code which is working, used with Arduino is: 

#include <Wire.h>

uint8_t data;
int nByte = 0;
byte lectura[4];
unsigned long valor = 0;


void setup()
{
  Wire.begin(0x50);                // join i2c bus with address #4
  Wire.onReceive(receiveEvent); // register event
  Serial.begin(9600);           // start serial for output
}

void loop()
{
  delay(100);
}

// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany)
{
  while (Wire.available() > 0){ // loop through all but the last
    data = Wire.read(); // receive byte as a character
    lectura[nByte]=data;
    nByte++;
    if(nByte % 4 == 0){
      nByte = 0;
      valor = (unsigned long)lectura[3] + ((unsigned long)lectura[2]<<8) + ((unsigned long)lectura[1]<<16) + ((unsigned long)lectura[0]<<24);
      Serial.println(valor);
    }
  }
  
}

  • No, the launchpad doesn't include pull-up resistors on I2C signals. 

    This device (TMS570LS1224PGE) has one I2C module, but the I2C signals (pin 3 and pin 4) are muxed with MibSPI pins. Please configure the pinmux properly to use those two pins as I2C.

  • I have configured the pins as I2C and I am using J11 pins 8 and 9 as SCL and SDA in the launchpad with 2 pull-up resistors at 3.3 V. It is still not working. With the oscilloscope, I just see the 3.3V at SCL and SDA lines. When I run the debug it is working correctly until the line: i2cReceive(i2cREG1, DATA_COUNT, RX_Data_Slave); on this line, it goes in a while in i2c.c that is:
    while ((i2c->STR & (uint32)I2C_RX_INT) == 0U)
    {
    } /* Wait */

    and stay there. Which could be the problem?

  • It is waiting for the received data. Please check slave datasheet to make sure your code follows its communication protocol.