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.

[参考译文] LAUNCHCC3235MOD:尽可能缩短获取温度的调用持续时间

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

https://e2e.ti.com/support/wireless-connectivity/wi-fi-group/wifi/f/wi-fi-forum/1278781/launchcc3235mod-minimizing-duration-of-call-to-get-temperature

器件型号:LAUNCHCC3235MOD

我可以在其他地方初始化并仅在低温环境中

 

// main_rtos
 Board_init();
    GPIO_init();
    I2C_init();
    GPIO_setConfig(CONFIG_GPIO_LED_0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
   #ifdef CONFIG_GPIO_TMP_EN
       GPIO_setConfig(CONFIG_GPIO_TMP_EN, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_HIGH);
       /* Allow the sensor to power on */
       sleep(1);
   #endif
    /* Set priority and stack size attributes */
//...
// tcpecho.c
void static i2c0 (void){
    uint16_t sample;
        int16_t temperature;
        uint8_t txBuffer[1];
        uint8_t rxBuffer[2];
        int8_t i;
        I2C_Handle i2c;
        I2C_Params i2cParams;
        I2C_Transaction i2cTransaction;

        /* Call driver init functions */
        //Display_init();
        //GPIO_init();
        I2C_init();

        /* Configure the LED and if applicable, the TMP_EN pin */
    //    GPIO_setConfig(CONFIG_GPIO_LED_0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    #ifdef CONFIG_GPIO_TMP_EN
        GPIO_setConfig(CONFIG_GPIO_TMP_EN, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_HIGH);
        /* Allow the sensor to power on */
        sleep(1);
    #endif


        /* Turn on user LED */
        GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON);
        Display_printf(display, 0, 0, "Starting the i2ctmp example\n");

        /* Create I2C for usage */
        I2C_Params_init(&i2cParams);
        i2cParams.bitRate = I2C_400kHz;
        i2c               = I2C_open(CONFIG_I2C_TMP, &i2cParams);
        if (i2c == NULL)
        {
            Display_printf(display, 0, 0, "Error Initializing I2C\n");
            while (1) {}
        }
        else
        {
            Display_printf(display, 0, 0, "I2C Initialized!\n");
        }

        /* Common I2C transaction setup */
        i2cTransaction.writeBuf   = txBuffer;
        i2cTransaction.writeCount = 1;
        i2cTransaction.readBuf    = rxBuffer;
        i2cTransaction.readCount  = 0;

        /*
         * Determine which I2C sensors are present by querying known I2C
         * target addresses.
         */
        for (i = TMP_COUNT - 1; i >= 0; i--)
        {
            i2cTransaction.targetAddress = sensors[i].address;
            txBuffer[0]                  = sensors[i].resultReg;

            if (I2C_transfer(i2c, &i2cTransaction))
            {
                targetAddress = sensors[i].address;
                Display_printf(display,
                               0,
                               0,
                               "Detected TMP%s sensor with target"
                               " address 0x%x",
                               sensors[i].id,
                               sensors[i].address);
            }
            else
            {
                i2cErrorHandler(&i2cTransaction, display);
            }
        }

        /* If we never assigned a target address */
        if (targetAddress == 0)
        {
            Display_printf(display, 0, 0, "Failed to detect a sensor!");
            I2C_close(i2c);
            while (1) {}
        }

        Display_printf(display, 0, 0, "\nUsing last known sensor for samples.");
        i2cTransaction.targetAddress = targetAddress;

        /* Take 3 samples and print them out onto the console */
        i2cTransaction.readCount = 2;
        for (sample = 0; sample < 3; sample++)
        {
            if (I2C_transfer(i2c, &i2cTransaction))
            {
                /*
                 * Extract degrees C from the received data;
                 * see TMP sensor datasheet
                 */
                temperature = (rxBuffer[0] << 8) | (rxBuffer[1]);
                temperature *= 0.0078125;

                Display_printf(display, 0, 0, "Sample %u: %d C", sample, temperature);
            }
            else
            {
                i2cErrorHandler(&i2cTransaction, display);
            }

            /* Sleep for 1 second */
            sleep(1);
        }

        I2C_close(i2c);
        Display_printf(display, 0, 0, "I2C closed!");




}

许多没有被删除的尝试似乎都失败了。 在如此微小的故障下,我似乎使用 platform.c 中的主机名而不是固定的 IP 地址,从而使路由器和/或本地 AP 受到困扰。 我想这应该是另一个问题。

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

    您好、Malcolm:

    我不确定我是否理解您的问题、您有没有失败? 似乎你修改了 I2CTMP 示例。 您能进一步解释一下您在应用中想要实现的目标吗?

    此致、

    罗格利奥

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

    本质上、我已经将 i2c 示例代码粘贴到函数中、然后粘贴到获取温度的最快调用、放入一次性初始化代码并在其他位置关闭、或者仅作为一次初始化关闭。 如果需要执行所有步骤、例如等待一秒钟的电源开启、那么我想知道这一点。 在一些运行速度相对较快的代码中、我不想等待超过一秒钟、我希望使用一个计时器并写入循环缓冲区、以便在调用获取最新温度时能够快速执行。 我还在努力通过 SNTP 设置时钟(从不似乎设置时钟)、然后获取随温度变化的时间戳。

    连接的问题似乎是多个, 15 到20,连接与测试程序与我的 AP 点( ruckus 7984)后得到修复,重新启动后,它与路由器(rv040g)无关。

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

    SNTP 时间工作、时钟设置和时间戳完成。 我将在清理后发布。 有关 ic2的问题仍然存在。

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

    尊敬的 Malcom:

    快速看一下您的代码、我看到您尝试对 I2C 进行两次初始化。 对于最高效的代码、我所要做的就是初始化所有内容(包括启用温度传感器)、然后在一个独立线程上执行从传感器到器件的 I2C 事务。 至于1秒睡眠、Im 不确定 打开传感器需要多长时间、但只要在器件通电之前没有调用来执行事务、您就可能面临1秒内无法睡眠的风险。

    此致、

    罗格利奥