主题中讨论的其他器件:MSPM0G3507、 SysConfig
我正在修改 LaunchPad 的 timx_timer_mode_periodic_standby_LP_MSPM0G3507_nortos_ticlang 示例。
我要做的是、将其设置为使用40M 晶体并将计时器周期设置为1ms。 不过、我的表现似乎达到了20%左右、
我已经以这种方式设置了配置:


请注意、上面注明周期应为1ms
但我的周期实际上是1.25ms:

仅供参考、计数器设置为4999
下面是代码:
#include "ti_msp_dl_config.h"
/* ((32KHz / (32+1)) * 0.5s) = 45 - 1 = 495 due to N+1 ticks */
#define TIMER_500_MILLISECONDS_TICKS (495)
/* ((32KHz / (32+1)) * 0.05s) = 50 - 1 = 49 due to N+1 ticks */
#define TIMER_50_MILLISECONDS_TICKS (49)
volatile uint32_t SetCount;
int main(void)
{
uint32_t setcount;
SYSCFG_DL_init();
SetCount = DL_Timer_getLoadValue(TIMER_0_INST);
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)
{
switch (DL_TimerG_getPendingInterrupt(TIMER_0_INST)) {
case DL_TIMER_IIDX_ZERO:
/*
* Counter stopped to avoid a conflict with the timer reading
* the LOAD value while it's being set
*/
//DL_TimerG_stopCounter(TIMER_0_INST);
//DL_Timer_setLoadValue(TIMER_0_INST, count);
/*
* By default, this should load the new count value and count down
* from there (CVAE = 0)
*/
//DL_TimerG_startCounter(TIMER_0_INST);
DL_GPIO_togglePins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN);
break;
default:
break;
}
}




