Other Parts Discussed in Thread: MSPM0G3507, SYSCONFIG
I am modifying the timx_timer_mode_periodic_standby_LP_MSPM0G3507_nortos_ticlang example for my Launch pad.
What I am trying to do is set it up to use the 40M crystal and have a timer period of 1 ms. However, I seem to be 20% or so off
I have set up the config this way:
Note that it says that the period should be 1 ms
But my period is actually 1.25 ms:
FYI, the counter is set to 4999
Here is the code:
#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; } }