Tool/software: TI-RTOS
I tried to communicate using smbus on tm4c123gh6pm. Hrer is my code. I does not receive in g_pucSlaveRxBuffer.
void SMBusInitonI2C(void) {
//
// Enable the peripherals for the SMBus master.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
//
// Configure the required pins for I2C0.
//
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOB))
{
}
GPIOPinConfigure(GPIO_PB2_I2C0SCL);
GPIOPinConfigure(GPIO_PB3_I2C0SDA);
GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2);
GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);
//
// Configure the IO mux so that the I2C pins for I2C0 are on PB2/3.
//
//
// Initialize the master SMBus port.
//
SMBusMasterInit(&g_sMaster, I2C0_BASE, SysCtlClockGet());
I2CIntRegister(GPIO_PORTB_BASE,&SMBusMasterIntHandler);
// Enable master interrupts.
//
SMBusMasterIntEnable(&g_sMaster);
I2CMasterEnable(I2C0_BASE);
IntMasterEnable();
}
U8_t readFromSlave(U8_t device_address, U8_t device_register) {
int i;
SMBusPECEnable(&g_sMaster);
returnStatus = SMBusMasterByteWordRead(&g_sMaster, device_address, device_register, g_pucSlaveRxBuffer, 2);
UARTprintf("Status: %d \r\n",returnStatus);
for(i=0; i<2; i++) {
UARTprintf("%d \r\n",g_pucSlaveRxBuffer[i]);
}
return 0;
}
If anyone has done SMBus communication please help me...