CC1310: Help with I2C Temperature Sensor on Sensor Controller Unit: Delayed Readings Issue

Part Number: CC1310

Tool/software:

I’m currently working on reading a temperature sensor over I2C using the Sensor Controller Unit (SCU). However, I’m encountering an issue that I’m struggling to resolve.

When I manually trigger the SCU execution using the command "scifSwTriggerExecutionCodeNbl(1 << SCIF_TEMP_TASK_ID);", the output from the Sensor Controller Unit returns 0. However, when I examine the I2C signals using a logic analyzer, I can see that a value other than 0 is being read (see the included picture).

Here’s the peculiar part: when I execute the code again, the value that was read during the last execution is outputted by the SCU to the main MCU. Essentially, I’m always getting the reading from the previous execution (n-1 reading).

My code from Code Composer Studio

scifSwTriggerExecutionCodeNbl(1 << SCIF_TEMP_TASK_ID);
uint16_t readingFromSCU =
	scifTaskData.Temp.output.temperature;

My code from Sensor Controller Studio

i2cStart();
i2cTx((0x48 << 1) | I2C_OP_WRITE);
i2cTx(0x00);

if (state.i2cStatus == 0x0000) {
    U16 MSB;
    U16 LSB;
    i2cRepeatedStart();
    i2cTx((0x48 << 1) | I2C_OP_READ);
    i2cRxAck(MSB);
    i2cRxNack(LSB);
    output.temperature = ((MSB << 8) | LSB);
}
i2cStop();

From what I’ve understood so far, it seems like the SCU is initiating a non-blocking I2C operation. On the first execution, the value isn’t available (hence 0), and on subsequent executions, I receive the value read during the prior execution.

I’m trying to determine if there’s a way to retrieve the current value during the same execution cycle. Is this behavior inherent to how the SCU handles I2C operations, and if so, is there a workaround to achieve my goal?

Any help would be greatly appreciated

  • Hi,

    So i was able to solve this by using the "fwGenAlertInterrupt();" function of the Sensor Controller Unit. The SCU triggers the interrupt when the i2c read is finished.


    On the man MCU instead of immediately reading the output variable after executing the "Execution code" of the SCU task i wait until i receive the wakeup call from the SCU and then i read the output from the SCU.

    In summary, if you don't actively wait for the i2c read to finish then you will either get a 0 or the last read value from the sensor depending on how your code is implemented. This is true for every I2C read operation, but typically, you can choose between a blocking and a non-blocking approach. However, since the SCU only supports the non-blocking method, I effectively implemented a blocking mechanism using the SCU.

    Greetings

    RLB