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);
}