LPC54608 WWDT Timeout Value

cancel
Showing results for 
Search instead for 
Did you mean: 

LPC54608 WWDT Timeout Value

327 Views
rex_lam
Contributor IV

I have been using the OM13092 board to test the LPC54608 WWDT feature. Here is an excerpt from the WWDT example program:

#define WDT_CLK_FREQ CLOCK_GetFreq(kCLOCK_WdtOsc)

#if !defined (FSL_FEATURE_WWDT_HAS_NO_PDCFG) || (!FSL_FEATURE_WWDT_HAS_NO_PDCFG)
    POWER_DisablePD(kPDRUNCFG_PD_WDT_OSC);
#endif

    /* The WDT divides the input frequency into it by 4 */
    wdtFreq = WDT_CLK_FREQ / 4;
    NVIC_EnableIRQ(APP_WDT_IRQn);
    WWDT_GetDefaultConfig(&config);

    /*
     * Set watchdog feed time constant to approximately 2s
     * Set watchdog warning time to 512 ticks after feed time constant
     * Set watchdog window time to 1s
     */
    config.timeoutValue = wdtFreq * 2;
    //config.warningValue = 512;
    //config.windowValue = wdtFreq * 1;
    /* Configure WWDT to reset on timeout */
    //config.enableWatchdogReset = true;
    WWDT_Init(WWDT, &config);

According to the comments, wdtFreq*2 should be approximately 2s. In my tests, it came out to about 1.56s, which is much less than 2. The return value of CLOCK_GetFreq(kCLOCK_WdtOsc) is 500000, and thus wdtFreq is 125000. The value of SystemCoreClock is 48000000. I used the SysTick timer to measure the watchdog time:

    SysTick_Config(CLOCK_GetFreq(kCLOCK_BusClk)/1000);

From WDTOSCCTRL, DIVSEL=0 (divide by 2), and FREQSEL=5 (1.0MHz). This explains why WDT_CLK_FREQ = 500000 but it doesn't explain why the actual timeout is off by a factor of 1.28. I changed wdtFreq to 160000 (125000x1.28), and then the expected timeout is correct, i.e. the watchdog times out accurately for 1s, 2s, 5s, etc. with wdtFreq=160000. Can anyone explain why that is so?

Labels (1)
0 Kudos
2 Replies

94 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Rex Lam,

    Please check the user manual description:

pastedImage_1.png

So, actually, the watchdog clock have the accuracy, it is +/-40%, this is very larger, as you know, even you get 1.56s, the accuracy is about 22%, it still meet the watchdog demand.

If you don't believe it, you can use the clock out to check the watchdog clk, this clock should already have the accuracy problem, this is the root problem caused the 1.56S time out problem.

Actually, it is not the issue, it is just the chip feature.

Wish it helps you!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

94 Views
rex_lam
Contributor IV

Kerry,

Thank you for the response. I have been trying to measure the frequency. Here is the code I used.

    INPUTMUX_Type *input_mux = INPUTMUX;
    input_mux->FREQMEAS_REF = INPUTMUX_FREQMEAS_REF_CLKIN(2);       // reference = fro_hf
    input_mux->FREQMEAS_TARGET = INPUTMUX_FREQMEAS_TARGET_CLKIN(3); // target = wdt_clk

    // start measuring
    SYSCON_Type *syscon = SYSCON;
    syscon->FREQMECTRL = SYSCON_FREQMECTRL_PROG(1);

    while ((syscon->FREQMECTRL & SYSCON_FREQMECTRL_PROG_MASK) == SYSCON_FREQMECTRL_PROG_MASK);

    uint32_t capval = SYSCON_FREQMECTRL_CAPVAL(syscon->FREQMECTRL);
    // Ftarget = (CAPVAL - 2) x Fref /2^14
    uint32_t target_freq = ((capval - 2) * SystemCoreClock) >> 14;
    PRINTF("capval=%d,target freq=%d\r\n", capval, target_freq);

After setting input_mux->FREQMEAS_REF and input_mux->FREQMEAS_TARGET, these registers still show a value of 0xF. Do I need to initialize anything else to use the frequency measure function?

Rex

0 Kudos