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.

TM4C129LNCZAD: I2C Function with Repeated Start

Part Number: TM4C129LNCZAD

Hello Team,

I'm writing on behalf of a customer we're supporting at CSC. He needs help with his inquiry below:

I am trying to utilize a dev tool from MikroElektronica Mikromedia 5 for Tiva. It uses a TM4C129LNCZAD chip and the I2C functionality seems tricky. I am trying to follow the steps listed in the DS (pages 1448-1449 Master Receive Multiple bytes following a Master Receive after Master Transmit with Repeated Start) to set up an I2C transfer with a Melexis 90614 IR Thermometer. I am trying to write the code mostly with direct register writes because their library functions don't seem to build well for me. Here is my example code with descriptions in comments about where it derails. Can you offer any assistance?

void IrThermoMeasure()
{
float measuredTemperature = 0.0;
char text[10];
char Tdata_[3];

I2C4_MCLKOCNT = 0xDA;
I2C4_Enable();
I2C4_MSA = (0x5A << 1) + 0; //Address 0x5A, plus 0 for write
I2C4_MDR = 0x07; //Command for RAM Access, Address 0x07
I2C4_MCS = 0x03; //Issue Write Start bit, Run
Delay_us(1);
while(I2C4_MCS.B0 != 0)
{}
I2C4_MSA = (0x5A << 1) + 1; //Address 0x5A, plus 1 for read
//Above this comment, it will issue the address and write 0x07
I2C4_MCS = 0x0B; //Rec with Ack Req, Start bit, and Run
Delay_us(1);
while(I2C4_MCS.B0 != 0)
{}
Tdata_[0] = I2C4_MDR;
//Above this comment, the flow is Start bit, Addr, 0x07, Start bit, Addr, one byte of data from IrThermo, and the clk pin does not release (it should not)
//In other words, to here, it seems to work properly.
I2C4_MCS = 0x09; //Receive one byte of data
Delay_us(1);
while(I2C4_MCS.B0 != 0)
{}
I2C4_MCS = 0x05; //Write the address and receive one byte of data with a Stop bit
Delay_us(1);
while(I2C4_MCS.B0 != 0)
{}
Delay_ms(1);
//This last line is what messes everything up. The flow now goes
// Start bit, Addr, 0x07, 0x07, Stop bit
// If I change what is in MDR before this, it sends out what was in MDR as the last byte.
// It seems to somehow change itself to write function instead of read

// I2C4_Disable();

// measuredTemperature = ((int)Tdata_[0] + ((int)Tdata_[1]<<8)) * 0.02;


// measuredTemperature = irthrm3v3_getTobject();
// FloatToStr(measuredTemperature,text);
// TempButton.Caption = Tdata_;
// IntToStr(text, Tdata_[0]);
// TempButton.Caption = text;
// DrawRoundButton(&TempButton);
}

The initialization works and I get some data, but trying to get anything more than 1 byte (I need 3) simply results in the Master sending out the data in MDR twice and that is it. It seems to switch back to write mode.

Thank you,
Travis