Other Parts Discussed in Thread: MSPM0G3507
Tool/software:
I'm using the sysctl_lfxt_standby_LP_MSPM0G3507_nortos_ticlang project from the mspm0_sdk_2_04_00_06 SDK.
The only change I made in syscfg is setting the Timer Clock Prescaler from 129 to 1.
Based on the code I'm using, one cycle should be 100 ms. However, I'm noticing a 122 µs difference between debug and non-debug modes — it’s 100.143 ms while debugging and 100.265 ms when running normally. So why is there a 122 µs difference?
#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;
}
}