Thread 中讨论的其他器件:MSPM0G3507
工具/软件:
我正在使用 sysctl_lfxt_standby_LP_MSPM0G3507_nortos_ticlang中的工程 mspm0_sdk_2_04_00_06SDK 中找到 。
我在中所做的唯一更改syscfg是将计时器时钟预分频器从 129 设置为 1。
根据我使用的代码、一个周期应该是 100ms。 但是、我注意到 122µs 在调试模式和非调试模式之间的区别 — 调试模式时为 100.143ms、正常运行时为 100.265ms。 那么 122µs 为什么有区别呢?
#include "ti_msp_dl_config.h"
#define TIMER_75_MILLISECONDS_TICKS (2458)
#define TIMER_25_MILLISECONDS_TICKS (820)
int main(void)
{
SYSCFG_DL_init();
NVIC_EnableIRQ(TIMER_0_INST_INT_IRQN);
DL_SYSCTL_enableSleepOnExit();
DL_TimerG_startCounter(TIMER_0_INST);
while (1) {
__WFI();
}
}
void TIMER_0_INST_IRQHandler(void)
{
static uint32_t count = TIMER_75_MILLISECONDS_TICKS;
switch (DL_TimerG_getPendingInterrupt(TIMER_0_INST)) {
case DL_TIMER_IIDX_ZERO
DL_TimerG_stopCounter(TIMER_0_INST);
if (count > TIMER_25_MILLISECONDS_TICKS) {
count = TIMER_25_MILLISECONDS_TICKS;
} else {
count = TIMER_75_MILLISECONDS_TICKS;
}
DL_Timer_setLoadValue(TIMER_0_INST, count);
DL_TimerG_startCounter(TIMER_0_INST);
DL_GPIO_togglePins(GPIO_LEDS_PORT,
(GPIO_LEDS_USER_LED_1_PIN));
break;
default:
break;
}
}