Other Parts Discussed in Thread: ENERGYTRACE
主题中讨论的其他器件:ENERGYTRACE
如何在 TI 配置计时器。 请为我提供相同的示例代码。 我曾尝试使用此代码、但不起作用。

此外 、我还在 CCS 中使用了 Energytrace 选项。 它显示4 - 5天电池寿命,我不知道它是否显示正确或错误。 请确认。
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.
Other Parts Discussed in Thread: ENERGYTRACE
如何在 TI 配置计时器。 请为我提供相同的示例代码。 我曾尝试使用此代码、但不起作用。

此外 、我还在 CCS 中使用了 Energytrace 选项。 它显示4 - 5天电池寿命,我不知道它是否显示正确或错误。 请确认。
大家好、 Ankit Jaiswal、
在查看您的代码片段时、您似乎没有包含"LGPTimerLPF3_start"、它不会启动计时器、这将解释计时器为何不工作。 由于该器件从不进入低功耗模式、因此功耗相对较高(对于以下代码、I 测量结果为~1.5天、因为 CPU 始终处于运行状态+ GPIO、如果我卸下 GPIO 护盖以将其断开、则为6天)。
下面是我根据 TI 驱动程序库改编的示例:
int count = 0;
int val = 0;
LGPTimerLPF3_Handle hTimer;
void timerCallback(LGPTimerLPF3_Handle lgptHandle, LGPTimerLPF3_IntMask interruptMask) {
count++;
val = count;
}
/*
* ======== mainThread ========
*/
void *mainThread(void *arg0)
{
/* 1 second delay */
uint32_t time = 1;
/* Call driver init functions */
GPIO_init();
/* Configure the LED pin */
GPIO_setConfig(CONFIG_GPIO_LED_0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
GPIO_setConfig(CONFIG_GPIO_LED_1, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
uint32_t counterTarget;
hTimer = NULL;
LGPTimerLPF3_Params params;
LGPTimerLPF3_Params_init(¶ms);
params.hwiCallbackFxn = timerCallback;
hTimer = LGPTimerLPF3_open(CONFIG_LGPTIMER_0, ¶ms);
if(hTimer == NULL) {
//Log_error0("Failed to open LGPTimer");
//Task_exit();
}
counterTarget = 48000; // 1 ms with a system clock of 48 MHz
LGPTimerLPF3_setInitialCounterTarget(hTimer, counterTarget, true);
LGPTimerLPF3_enableInterrupt(hTimer, LGPTimerLPF3_INT_TGT);
LGPTimerLPF3_start(hTimer, LGPTimerLPF3_CTL_MODE_UP_PER);
sleep(time);
while (1)
{
sleep(time);
GPIO_toggle(CONFIG_GPIO_LED_0);
}
}
谢谢。
A·F
大家好、 Ankit Jaiswal、
为了帮助减少功耗、我先后使用了 LGPTimerLPF3_STOP 和 LGPTimerLPF3_Close 来停止/关闭定时器;有关如何正确停止定时器的详细信息包含在 LGPTimerLPFE.h 文件中。 计时器关闭后、功耗会 大幅降低、而我测得的数据是4年(使用 CCS EnergyTrace 工具并关闭 GPIO)、而不是6天的电池寿命。 为了实现 这一点、我使用了以下代码片段(empty.c 项目的修改版本):
void *mainThread(void *arg0)
{
/* 1 second delay */
uint32_t time = 1;
/* Call driver init functions */
GPIO_init();
/* Configure the LED pin */
GPIO_setConfig(CONFIG_GPIO_LED_0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
GPIO_setConfig(CONFIG_GPIO_LED_1, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
uint32_t counterTarget;
hTimer = NULL;
LGPTimerLPF3_Params params;
LGPTimerLPF3_Params_init(¶ms);
params.hwiCallbackFxn = timerCallback;
hTimer = LGPTimerLPF3_open(CONFIG_LGPTIMER_0, ¶ms);
if(hTimer == NULL) {
//Log_error0("Failed to open LGPTimer");
//Task_exit();
}
counterTarget = 48000; // 1 ms with a system clock of 48 MHz
LGPTimerLPF3_setInitialCounterTarget(hTimer, counterTarget, true);
LGPTimerLPF3_enableInterrupt(hTimer, LGPTimerLPF3_INT_TGT);
LGPTimerLPF3_start(hTimer, LGPTimerLPF3_CTL_MODE_UP_PER); //LGPTimerLPF3_CTL_MODE_UP_ONCE
sleep(time);
LGPTimerLPF3_stop(hTimer);
LGPTimerLPF3_close(hTimer);
while (1)
{
sleep(time);
GPIO_toggle(CONFIG_GPIO_LED_0);
}
}
谢谢。
A·F