Hello,
i got problem with transmission between tiva and mpl3115a2 sensor. My code:
GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_6 | GPIO_PIN_7);
// GPIOPadConfigSet( GPIO_PORTA_BASE, GPIO_PIN_6 | GPIO_PIN_7, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_OD_WPU);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinTypeI2CSCL(GPIO_PORTA_BASE, GPIO_PIN_6); // special I2CSCL treatment for M4F devices
GPIOPinTypeI2C(GPIO_PORTA_BASE, GPIO_PIN_7);
GPIOPinConfigure(GPIO_PA6_I2C1SCL);
GPIOPinConfigure(GPIO_PA7_I2C1SDA);
SysCtlPeripheralEnable( SYSCTL_PERIPH_I2C1);
I2CMasterInitExpClk(I2C1_BASE, SysCtlClockGet(), false);
SysCtlDelay(10000);
and function that i use for read:
void i2c_sent_read(char addre, unsigned long data,unsigned long *receive){
unsigned long k=0;
I2CMasterSlaveAddrSet(I2C1_BASE,addre,true);
I2CMasterDataPut(I2C1_BASE,data);
I2CMasterControl(I2C1_BASE,I2C_MASTER_CMD_SINGLE_RECEIVE);
while(I2CMasterBusy(I2C1_BASE)){}
//I2CMasterControl(I2C1_BASE,I2C_MASTER_CMD_SINGLE_RECEIVE);
while(I2CMasterBusy(I2C1_BASE)){}
k=I2CMasterErr(I2C1_BASE);
*receive=I2CMasterDataGet(I2C1_BASE);
}
Result: i read error value 4 (I2C_MASTER_ERR_ADDR_ACK), and value that i read from buffer is 255. I can't read anything from sensor.
Thanks for help