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.

TM4C123GH6PGE: Regarding I2C based D6f-ph0505ad3

Part Number: TM4C123GH6PGE

hi

i am currently working on  I2C communication in tm4c123gh6pge  board,the main thing is....

i want to collect the values of pressure from sensor(D6F-PH0505AD3) to tm4c123gh6pge through I2C communication. But i am getting the unknown values as response and i implemented the code as below

SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C3);
SysCtlPeripheralReset(SYSCTL_PERIPH_I2C3);
GPIOPinConfigure(GPIO_PD0_I2C3SCL);
GPIOPinConfigure(GPIO_PD1_I2C3SDA);
GPIOPinTypeI2CSCL(GPIO_PORTD_BASE, GPIO_PIN_0);
GPIOPinTypeI2C(GPIO_PORTD_BASE, GPIO_PIN_1);
I2CMasterInitExpClk(I2C3_BASE, SysCtlClockGet(), true);
I2CSlaveEnable(I2C3_BASE);
HWREG(I2C3_BASE + I2C_O_FIFOCTL) = 0x01;

I2CMasterSlaveAddrSet(I2C3_BASE, SLAVE_ADDRESS, true);
I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_BURST_SEND_START);
while(I2CMasterBusy(I2C3_BASE));

I2CMasterDataPut(I2C3_BASE,0X0B);                                                                                                                             // pressure sensor initialization
I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);
while(I2CMasterBusy(I2C3_BASE));

I2CMasterDataPut(I2C3_BASE,0X00);
I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);
while(I2CMasterBusy(I2C3_BASE));

///////// INTILIZED///////////////////

while(1)
{
I2CMasterSlaveAddrSet(I2C3_BASE, SLAVE_ADDRESS, true);                                                                       // serial control settings of pressure sensor to write data
I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_BURST_SEND_START);
while(I2CMasterBusy(I2C3_BASE));

I2CMasterDataPut(I2C3_BASE,0X00);
I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);
while(I2CMasterBusy(I2C3_BASE));

I2CMasterDataPut(I2C3_BASE,0XD0);
I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);
while(I2CMasterBusy(I2C3_BASE));

I2CMasterDataPut(I2C3_BASE,0X40);
I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);
while(I2CMasterBusy(I2C3_BASE));

I2CMasterDataPut(I2C3_BASE,0X18);
I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);
while(I2CMasterBusy(I2C3_BASE));

I2CMasterDataPut(I2C3_BASE,0X06);
I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);
while(I2CMasterBusy(I2C3_BASE));

I2CMasterSlaveAddrSet(I2C3_BASE, SLAVE_ADDRESS, true);
I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_BURST_SEND_STOP);
while(I2CMasterBusy(I2C3_BASE));

SysCtlDelay(SysCtlClockGet()/30);
//// ADDRESS write/////////////////////
I2CMasterSlaveAddrSet(I2C3_BASE, SLAVE_ADDRESS, true);                                                                                                     // serial control settings of pressure sensor to read data
I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_BURST_SEND_START);
while(I2CMasterBusy(I2C3_BASE));

I2CMasterDataPut(I2C3_BASE,0X00);
I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);
while(I2CMasterBusy(I2C3_BASE));

I2CMasterDataPut(I2C3_BASE,0XD0);
I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);
while(I2CMasterBusy(I2C3_BASE));

I2CMasterDataPut(I2C3_BASE,0X51);
I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);
while(I2CMasterBusy(I2C3_BASE));

I2CMasterDataPut(I2C3_BASE,0X2C);
I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);
while(I2CMasterBusy(I2C3_BASE));

I2CMasterDataPut(I2C3_BASE,0X07);
I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);
while(I2CMasterBusy(I2C3_BASE));

I2CMasterSlaveAddrSet(I2C3_BASE, SLAVE_ADDRESS, true);
I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_BURST_SEND_STOP);
while(I2CMasterBusy(I2C3_BASE));

SysCtlDelay(SysCtlClockGet()/30);
////WRITE
I2CMasterSlaveAddrSet(I2C3_BASE, SLAVE_ADDRESS, true);                                                                                                          // request to read data from read_buffer0
I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_BURST_SEND_START);
while(I2CMasterBusy(I2C3_BASE));

I2CMasterDataPut(I2C3_BASE,0X07);
I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_SINGLE_SEND);
while(I2CMasterBusy(I2C3_BASE));

I2CMasterSlaveAddrSet(I2C3_BASE, SLAVE_ADDRESS1, true);
I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_BURST_SEND_START);
while(I2CMasterBusy(I2C3_BASE));


SysCtlDelay(SysCtlClockGet());
SysCtlDelay(SysCtlClockGet());

I2CMasterSlaveAddrSet(I2C3_BASE, SLAVE_ADDRESS1, true);                                                                                            // reading data from read_buffer0
I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);
while(I2CMasterBusy(I2C3_BASE));
slave_data=I2CMasterDataGet(I2C3_BASE);

I2CMasterSlaveAddrSet(I2C3_BASE, SLAVE_ADDRESS1, true);
I2CMasterControl(I2C3_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);
while(I2CMasterBusy(I2C3_BASE));
slave_data1=I2CMasterDataGet(I2C3_BASE);
}

  • Ravi,
    The poster for the thread below had a similar situation, receiving unexpected values from a sensor.
    e2e.ti.com/.../2223960
    Although the communication standard is different, that post might teach you what are the things you need to check, and solution might apply to your case.
    Bruno
  • While poster notes use of, "tm4c123gh6pge" - and that is NOT the MCU resident upon the LPad - it MUST be noted that the, "123-LPad" (delightfully and forever) BINDS poster's PDO & PD1 (his I2C choice pins) to PB6 & PB7!

    As a consulting & diagnostic firm - often we've observed that the "123-LPad" design has been (substantially) duplicated- by those, "spinning their own board!"      Thus - the odds for the "propagation of that UNWISE, MULTI-PIN,  .Cross-Connect" rise high!

    As my eyes may have been "over-taxed" (from reviewing Rube Goldberg diagrams - earlier) NOT ONE "I2CMasterDataGet()" function call appeared to my view!     Such would surely account for, "unknown values" (unknown to poster - and via the vague report - to all here - as well...)

    External pull-up Rs (upon JTAG) AND use of the properly placed, "I2CMasterDataGet()" - may (begin) to drive poster toward success...

    [edit] 12:50 CST - Now noted "two" calls to "I2CMasterDataGet()" - but  (only)  w/in the final 5 lines of poster code.     Can those 2 calls - isolated as they are - be sufficient?

    Might it be that the "great abundance" of  "I2CMasterDataPut()" function calls "were required by poster's slave" for its full configuration & set-up - and no necessity for "Data Gets" existed?     If so - my earlier diagnosis was wrong - yet (some) clear declaration of the program's flow & objectives (should) have been included - to prevent  those assisting - from, "blind path entry."