Other Parts Discussed in Thread: HDC2080
Tool/software: Code Composer Studio
I'm having trouble reading and writing data on the HDC2080 sensor, when I add some writing commands in a row, the data is not written to the sensor...
And if I try to read data sequentially, all readings return the same value, sometimes the same value as the first read, and sometimes the second read value.
What could this be?
void initI2C9(uint32_t clock1) { ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C9); ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_I2C9); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); ROM_GPIOPinConfigure(GPIO_PA0_I2C9SCL); ROM_GPIOPinConfigure(GPIO_PA1_I2C9SDA); ROM_GPIOPinTypeI2CSCL(GPIO_PORTA_BASE, GPIO_PIN_0); ROM_GPIOPinTypeI2C(GPIO_PORTA_BASE, GPIO_PIN_1); ROM_I2CMasterInitExpClk(I2C9_BASE, clock1, true); HWREG(I2C9_BASE + I2C_O_FIFOCTL) = 80008000; } uint8_t buf; uint8_t readI2C9(uint16_t device_address, uint16_t device_register) { ROM_I2CMasterSlaveAddrSet(I2C9_BASE, device_address, false); ROM_I2CMasterDataPut(I2C9_BASE, device_register); ROM_I2CMasterControl(I2C9_BASE, I2C_MASTER_CMD_SINGLE_SEND); while(ROM_I2CMasterBusy(I2C9_BASE)); ROM_I2CMasterSlaveAddrSet(I2C9_BASE, device_address, true); ROM_I2CMasterControl(I2C9_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE); while(ROM_I2CMasterBusy(I2C9_BASE)); buf= ROM_I2CMasterDataGet(I2C9_BASE); return(buf); } void writeI2C9(uint16_t device_address, uint16_t device_register, uint8_t device_data) { ROM_I2CMasterSlaveAddrSet(I2C9_BASE, device_address, false); ROM_I2CMasterDataPut(I2C9_BASE, device_register); ROM_I2CMasterControl(I2C9_BASE, I2C_MASTER_CMD_BURST_SEND_START); while(ROM_I2CMasterBusy(I2C9_BASE)); ROM_I2CMasterSlaveAddrSet(I2C9_BASE, device_address, true); ROM_I2CMasterDataPut(I2C9_BASE, device_data); ROM_I2CMasterControl(I2C9_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH); while(ROM_I2CMasterBusy(I2C9_BASE)); }