This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC1312R:如何通过从处理器引脚馈送来使用 I2C 读取 TEMP 数据

Guru**** 2558990 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/994258/cc1312r-how-to-read-temp-data-using-i2c-by-feeding-from-the-processor-pin

器件型号:CC1312R

大家好、

我使用的是 si7051温度传感器。 我正在从该传感器读取温度数据。 我在下面编写的代码正常工作。 当您从蓄电池(R38)向传感器馈电时、此代码是合适的。 但是、现在我想从微型假体引脚 (V_Temp_MCU)(R39)馈送

 您可以看到下面的温度传感器连接。 MCU 引脚设置为 ioid7。  

#define V_Temp_MCU IOID_7

当我使用电池通过 R38读取传感器时。 此代码目前已足够。 但我想修改代码、以便从 MCU 馈送。 我该怎么做? 我尝试设置 MCU 引脚1,然后设置0。 或0至1。 但当我检查调试模式时,代码不会进入 if (I2C_transfer (i2c,&i2cTransaction ))部分。

您对此问题有什么建议吗?

void Temperature_Function(UArg arg0, UArg arg1)
{
    uint8_t     txBuffer[1];
    uint8_t     rxBuffer[2];

    I2C_Handle      i2c;
    I2C_Params      i2cParams;
    I2C_Transaction i2cTransaction;
    I2C_init();
    I2C_Params_init(&i2cParams);

    i2cParams.bitRate = I2C_400kHz;
    i2c=I2C_open(CC1312_LAUNCHXL_I2C0, &i2cParams);

    if (i2c == NULL) {
//        Display_printf(display, 0, 0, "Error Initializing I2C\n");
        while (1);
    }
    txBuffer[0] = 0xE3;
    /* Common I2C transaction setup */
    i2cTransaction.writeBuf   = txBuffer;
    i2cTransaction.writeCount = 1;
    i2cTransaction.readBuf    = rxBuffer;
    i2cTransaction.readCount  = 2;
    i2cTransaction.slaveAddress = 0x40;

    while (1)
    {
        if(Temp_Read_Flag)
        {
            Temp_Read_Flag = 0;
            usleep(15); //14 bit temperature conversion needs 10+ms time to complete

            if (I2C_transfer(i2c, &i2cTransaction)) {
            /*
            * Extract degrees C from the received data;
            * see sensor datasheet
            */
            temperature = (rxBuffer[0] << 8) | (rxBuffer[1]);
            temperature = ((float)temperature*175.72)/65536 - 46.85;
            }
        }
    }
}

谢谢你  

BR

Bekir

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    通过 GPIO 为温度传感器供电不会是问题、因此工作正常。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    请注意、对于 I2C、100千欧通常过高。 将其与我们在 LaunchPad 上使用的器件进行比较。  

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我建议您先使用示波器来检查 SCL/SDA 信号。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    感谢大家的回答