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.

Getting Issue in I2C communication

Other Parts Discussed in Thread: TMS570LS1224

Hi Friends,

I am using TMS570LS1224 launchpad, And interfacing MAX6958 7-Segment driver. I2C communication is happening now but I am getting garbage data .

I have 4-digit 7-segment and it always shows 8888 on display.I am not getting why it is happening.I need help.

I tested MAX6958 driver with arduino Uno it is working fine.

here is arduino code:


void setup()
{
//Configure pin I/O
pinMode(motorPin, OUTPUT);
pinMode(potPin, INPUT);
pinMode(earOnePin, OUTPUT);
pinMode(earTwoPin, OUTPUT);
pinMode(earThreePin, OUTPUT);
pinMode(earFourPin, OUTPUT);
pinMode(domeOnePin, OUTPUT);
pinMode(domeTwoPin, OUTPUT);
pinMode(domeThreePin, OUTPUT);
pinMode(domeFourPin, OUTPUT);

//Generate random number for display
randomSeed(analogRead(A1));

//Initialize I2C and MAX6958 chip
Wire.begin();

Wire.beginTransmission(segDisplay);
Wire.write(0x01); //Decode mode command
Wire.write(0x0F); //Decode mode for digits 0-2
Wire.endTransmission(1);

Wire.beginTransmission(segDisplay);
Wire.write(0x02); //Intensity command
Wire.write(0x20); //0x00(min) to 0x3F(max)
Wire.endTransmission(1);

Wire.beginTransmission(segDisplay);
Wire.write(0x03); //Scan limit command
Wire.write(0x03); //Display digits 0-2
Wire.endTransmission(1);

Wire.beginTransmission(segDisplay);
Wire.write(0x04); //Configuration command
Wire.write(0x01); //Normal operation
Wire.endTransmission(1);
while(1)
{
Wire.beginTransmission(segDisplay);
Wire.write(0x20); //Set digit 0
Wire.write(0x0A); //Value 0
Wire.endTransmission(1);

Wire.beginTransmission(segDisplay);
Wire.write(0x21); //Set digit 1
Wire.write(0x01); //Value 1
Wire.endTransmission(1);
}
Wire.beginTransmission(segDisplay);
Wire.write(0x21); //Set digit 1
Wire.write(0x0B); //Value 1
Wire.endTransmission(1);

//Ramp up DC motor (possible issue with boost converter?)
analogWrite(motorPin, 50);
delay(500);
analogWrite(motorPin, 100);
delay(500);

//Set DC motor speed
analogWrite(motorPin, motorSpeed);
}

void loop()
{
//Update currentTime for LED timings
unsigned long currentTime = millis();

//Update ear lights
if(currentTime - earTime >= earInterval)
{
earTime = currentTime;

if(earOne == 1)
{
earOne = 0;
earTwo = 1;
earThree = 0;
earFour = 0;
}

else if(earTwo == 1)
{
earOne = 0;
earTwo = 0;
earThree = 1;
earFour = 0;
}

else if(earThree == 1)
{
earOne = 0;
earTwo = 0;
earThree = 0;
earFour = 1;
}

else
{
earOne = 1;
earTwo = 0;
earThree = 0;
earFour = 0;
}

digitalWrite(earOnePin, earOne);
digitalWrite(earTwoPin, earTwo);
digitalWrite(earThreePin, earThree);
digitalWrite(earFourPin, earFour);
}

//Update dome lights
if(currentTime - domeOneTime >= domeOneInterval)
{
domeOneTime = currentTime;
digitalWrite(domeOnePin, !digitalRead(domeOnePin));
}
if(currentTime - domeTwoTime >= domeTwoInterval)
{
domeTwoTime = currentTime;
digitalWrite(domeTwoPin, !digitalRead(domeTwoPin));
}
if(currentTime - domeThreeTime >= domeThreeInterval)
{
domeThreeTime = currentTime;
digitalWrite(domeThreePin, !digitalRead(domeThreePin));
}
if(currentTime - domeFourTime >= domeFourInterval)
{
domeFourTime = currentTime;
digitalWrite(domeFourPin, !digitalRead(domeFourPin));
}

//Update display numbers
if(currentTime - displayTime >= displayInterval)
{
displayTime = currentTime;

Wire.beginTransmission(segDisplay);
Wire.write(0x20); //Set digit 0
Wire.write((int)random(1,3)); //Random value between 1 and 2
Wire.endTransmission(1);

Wire.beginTransmission(segDisplay);
Wire.write(0x21); //Set digit 1
Wire.write((int)random(0,10)); //Random value between 0 and 9
Wire.endTransmission(1);
}
}

And here is my Launchpad code:

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

#define Master_Address 0x26
#define Slave_Address 0b0111000
#define num 0x0F
uint8_t TX_Data_Slave[10] = { 0x01,0x07,0x02,0x20,0x03,0x02,0x04,0x23,0x20,0x01};
/* USER CODE END */

void main(void)
{
/* USER CODE BEGIN (3) */
unsigned char data = 0;
int repeat = 0; int delay =0;

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

i2cSetMode(i2cREG1, I2C_MASTER);
/* Configure address of Slave to talk to */
i2cSetSlaveAdd(i2cREG1, Slave_Address);

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

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

/* Set mode as Master */
// i2cSetMode(i2cREG1, I2C_MASTER);

/* Set Stop after programmed Count */
i2cSetStop(i2cREG1);
// i2cSetSlaveAdd(i2cREG1, Slave_Address);
/* Transmit Start Condition */
i2cSetStart(i2cREG1);
while(1)
{
i2cSendByte(i2cREG1, TX_Data_Slave[data++]);
}

Regards,

Arvind.

  • Arvind,

    I would say you need to start simple. Get a scope or logic analyzer, and connect it to the I2C SCL, SDA wires.
    Then step through your code and just try to create one transfer. Compare the results on the pins with what you *want* to happen.
    That will probably be enough to tell you exactly what the issue is.

    Since you mention that the issue is not *no activity on the bus* it's probably something simple like the data format or the command set you are sending not being correct for the display. We definitely are not arduino compatible in any way shape or form so I wouldn't expect the arduino sketch to just port over with zero mods...

    Best Regards,
    Anthony
  • Hi Anthony,

    Thank you for your support, Now my Application is working fine. Thank you.

    Regards,

    Arvind.