Hello everyone, I have problem with I2C communication from my Lounchpad TM4C123gxl to proximity sensor ADPS9960. I init MCU, peripheral, and when try to read from sensor register I get 0xFF, When I try to read from Arduino board to the same sensor, code works good. So I am apparently doing something wrong and I don't know what. I connected pullups in SCL and SDA line, (10k. )Here is my I2C code :
void main(void) { SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_PLL | SYSCTL_OSC_INT | SYSCTL_XTAL_16MHZ); Configuration(); while(1) { Read_Inputs(); } } void I2C_Configuration() { SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0); SysCtlPeripheralReset(SYSCTL_PERIPH_I2C0); SysCtlPeripheralEnable(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); I2CMasterInitExpClk(I2C0_BASE, SysCtlClockGet(), false); HWREG(I2C0_BASE + I2C_O_FIFOCTL) = 80008000; } uint8_t I2CWriteDataByte(uint8_t slave_addr, uint8_t dev_reg, uint8_t data) { I2CMasterSlaveAddrSet(I2C0_BASE, slave_addr, false); I2CMasterDataPut(I2C0_BASE, dev_reg); I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_SEND); while(I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, data); I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH); while ( I2CMasterBusy(I2C0_BASE) ); return 1; } uint8_t I2CReadDataByte(uint8_t slave_addr, uint8_t slave_reg) { I2CMasterSlaveAddrSet(I2C0_BASE, slave_addr, false); I2CMasterDataPut(I2C0_BASE, slave_reg); I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_SEND); while(I2CMasterBusy(I2C0_BASE)); I2CMasterSlaveAddrSet(I2C0_BASE, slave_addr, true); I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE); while(I2CMasterBusy(I2C0_BASE)); return(I2CMasterDataGet(I2C0_BASE)); }