I am trying to read the temperature data from the temperature sensor: MPL115A2
But if I do "Task Testing" the variable "i2cStatus" from the state Data structure shows constantly 1, meaning there is an error or NAK.
And the output values "tempMSB" and "tempLSB" are constantly 1, too.
Below is the execution code.
// Configure and start the next measurement
i2cStart();
i2cTx((MPL115A2_ADDRESS<<1) | I2C_OP_WRITE); // Device address write command
i2cTx(MPL115A2_REGISTER_STARTCONVERSION); // Start conversion command
i2cTx(0x00); // Complete the passing of Start Conversion
i2cStop();
fwDelayUs(100000, FW_DELAY_RANGE_100_MS); // Delay for A/D conversion
// If successful ...
if (state.i2cStatus == 0x0000) {
i2cStart();
i2cTx((MPL115A2_ADDRESS<<1) | I2C_OP_READ); // Device address read command
i2cTx(MPL115A2_REGISTER_TEMP_MSB); // Access register
i2cRxNack(output.tempMSB); // Read Temperature MSB
i2cRxNack(output.tempLSB); // Read Temperature LSB
i2cStop();
}
// Schedule the next execution
fwScheduleTask(1);