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