Hi,
maybe I've just undertsood what's happening.
Scenario1, LPTMR wakeup @1khz and interrupt frequency @125hz. Prior to refresh the watchdog, system is waking up from LLS 1000times because of the LPTMR (1ms period) and 125 times because of the interrupt (8ms period). 'before' values are 1124ms.
--- interrupt enabled @ 125hz ---
log[5] -> { rtc = 0x3063F, before = 0x464, after = 0x0}
log[6] -> { rtc = 0x38749, before = 0x465, after = 0x0}
log[7] -> { rtc = 0x40854, before = 0x464, after = 0x0}
log[8] -> { rtc = 0x48961, before = 0x461, after = 0x0}
log[9] -> { rtc = 0x50A71, before = 0x462, after = 0x0}
Scenario2, LPTMR wakeup @20hz, and interrupt disabled. Prior to refresh the watchdog, system is waking up from LLS 20times because of the LPTMR (50ms period) and 0 times because of the interrupt. 'before' values are 20ms.
log[0] -> { rtc = 0x07A78, before = 0x1B, after = 0x0}
log[1] -> { rtc = 0x0FB4F, before = 0x14, after = 0x0}
log[2] -> { rtc = 0x17C28, before = 0x14, after = 0x0}
log[3] -> { rtc = 0x1FD00, before = 0x14, after = 0x0}
log[4] -> { rtc = 0x22DD8, before = 0x14, after = 0x0}
Scenario3, LPTMR wakeup @20hz and interrupt frequency @125hz. Prior to refresh the watchdog, system is waking up from LLS 20times because of the LPTMR (1ms period) and 125 times because of the interrupt (8 period). 'before' values are 20ms with interrupt disabled, and ~145ms with interrupt enabled.
log[0] -> { rtc = 0x20353, before = 0x1C, after = 0x0}
log[1] -> { rtc = 0x28423, before = 0x14, after = 0x0}
log[2] -> { rtc = 0x3052F, before = 0x14, after = 0x0}
log[3] -> { rtc = 0x3863B, before = 0x14, after = 0x0}
log[4] -> { rtc = 0x40747, before = 0x14, after = 0x0}
--- interrupt enabled @ 125hz ---
log[5] -> { rtc = 0x0003052F, before = 0x99, after = 0x0}
log[6] -> { rtc = 0x0003863B, before = 0x98, after = 0x0}
log[7] -> { rtc = 0x00040747, before = 0x96, after = 0x0}
log[8] -> { rtc = 0x00048854, before = 0x9A, after = 0x0}
log[9] -> { rtc = 0x00050961, before = 0x98, after = 0x0}
From what I'm seeing, it's like that WDOG counter is not incrementing while the CPU is in LLS, but it increments of 1 unit each wakeup from LLS.
This is my watchdog configuration: STOPEN bit is set correctly.
LDD_TDeviceData* WD_PE_Init(LDD_TUserData *UserDataPtr)
{
/* Allocate device structure */
WD_PE_TDeviceData *DeviceDataPrv;
/* {Default RTOS Adapter} Driver memory allocation: Dynamic allocation is simulated by a pointer to the static object */
DeviceDataPrv = &DeviceDataPrv__DEFAULT_RTOS_ALLOC;
DeviceDataPrv->UserDataPtr = UserDataPtr; /* Store the RTOS device structure */
/* Interrupt vector(s) allocation */
/* {Default RTOS Adapter} Set interrupt vector: IVT is static, ISR parameter is passed by the global variable */
INT_Watchdog__DEFAULT_RTOS_ISRPARAM = DeviceDataPrv;
/* NVICIP22: PRI22=0x80 */
NVICIP22 = NVIC_IP_PRI22(0x80);
/* NVICISER0: SETENA|=0x00400000 */
NVICISER0 |= NVIC_ISER_SETENA(0x00400000);
/* {Default RTOS Adapter} Critical section begin, general PE function is used */
EnterCritical();
/* WDOG_UNLOCK: WDOGUNLOCK=0xC520 */
WDOG_UNLOCK = WDOG_UNLOCK_WDOGUNLOCK(0xC520); /* Key 1 */
/* WDOG_UNLOCK: WDOGUNLOCK=0xD928 */
WDOG_UNLOCK = WDOG_UNLOCK_WDOGUNLOCK(0xD928); /* Key 2 */
/* WDOG_WINH: WINHIGH=0 */
WDOG_WINH = WDOG_WINH_WINHIGH(0x00); /* Setup window register high */
/* WDOG_WINL: WINLOW=0 */
WDOG_WINL = WDOG_WINL_WINLOW(0x00); /* Setup window register low */
/* WDOG_TOVALH: TOVALHIGH=0 */
WDOG_TOVALH = WDOG_TOVALH_TOVALHIGH(0x00); /* Setup time-out value register high */
/* WDOG_TOVALL: TOVALLOW=0x04B0 */
WDOG_TOVALL = WDOG_TOVALL_TOVALLOW(1300); /* Setup time-out value register low */
/* WDOG_PRESC: ??=0,??=0,??=0,??=0,??=0,PRESCVAL=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0 */
WDOG_PRESC = WDOG_PRESC_PRESCVAL(0x00); /* Setup status register */
/* WDOG_STCTRLL: INTFLG=1,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=1 */
WDOG_STCTRLL = (WDOG_STCTRLL_INTFLG_MASK | 0x01U); /* Setup status register */
/* WDOG_STCTRLH: ??=0,DISTESTWDOG=1,BYTESEL=0,TESTSEL=0,TESTWDOG=0,??=0,??=1,WAITEN=1,STOPEN=1,DBGEN=0,ALLOWUPDATE=1,WINEN=0,IRQRSTEN=1,CLKsrc=0,WDOGEN=1 */
WDOG_STCTRLH = WDOG_STCTRLH_DISTESTWDOG_MASK |
WDOG_STCTRLH_BYTESEL(0x00) |
WDOG_STCTRLH_WAITEN_MASK |
WDOG_STCTRLH_STOPEN_MASK |
WDOG_STCTRLH_ALLOWUPDATE_MASK |
WDOG_STCTRLH_IRQRSTEN_MASK |
WDOG_STCTRLH_WDOGEN_MASK |
0x0100U; /* Setup control register */
/* {Default RTOS Adapter} Critical section end, general PE function is used */
ExitCritical();
/* Registration of the device structure */
PE_LDD_RegisterDeviceStructure(PE_LDD_COMPONENT_WD_PE_ID,DeviceDataPrv);
return ((LDD_TDeviceData *)DeviceDataPrv); /* Return pointer to the device data structure */
}
If I enter in LLS with LPTMR disabled (no wakeup from LLS then), WD is not resetting, meaning that counter is not incrementing.