RT1050 EVKB - Using RTWDOG

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

RT1050 EVKB - Using RTWDOG

632 Views
jpgoncalves
Contributor I

Hello, 

How are are you? 

I am having a problem configuring the RTWDOG, as described below:

Sometimes in rtwdog initialization the code become stuck in the function RTWDOG_Unlock() waiting for the ULK flag (when ULK is 1 rtwdog is unlocked) to change from 0 to 1 ( Code below).  This happens in the call to RTWDOG_Unlock() inside RTWDOG_Init(). This problem dot not always happen. Sometimes the code works for days and then after a reset it becomes stuck.  

 

//In RTWDOG_Unlock. Sometimes code becomes stuck here after reset.
while ((base->CS & RTWDOG_CS_ULK_MASK) == 0U)
{
}

 

 

From the RT1050 reference manual i know that the rtwdog need to be configured in 255 bus cycles after reset. I am also using some parts from the rtwdog sdk (v2.9.1) example. The code that i am using is show below. I call the wdog_Init() inside SystemInitHook() to init rwdog configs close to reset. This code is the first to run on my application after startup.

 

//In file wdog.c
#define BSP_WDOG_CLK_FREQ 32768U
#define BSP_WDOG_TIMER_PRESC 256
#define DELAY_TIME 100000U

void wdog_Init(void)
{
    CLOCK_EnableClock(kCLOCK_Wdog3);

    /* @brief : Recommendation delay from NXP. Without that,
    * wdog can not be configured.
    *
    * @note Example note NXP:
    * When system is boot up, WDOG32 is disabled.
    * We must wait for at least 2.5
    * periods of wdog32 clock to reconfigure wodg32.
    * So Delay a while to wait for
    * the previous configuration taking effect.
    *
    */

    for (uint32_t temp = 0; temp < DELAY_TIME; temp++)
    {
        __NOP();
    }

    static rtwdog_config_t wdogConfig;

    RTWDOG_GetDefaultConfig(&wdogConfig);

    wdogConfig.enableUpdate = true;
    wdogConfig.workMode.enableDebug = false;
    wdogConfig.prescaler = kRTWDOG_ClockPrescalerDivide256;
    wdogConfig.timeoutValue = msec2WdogCount(WDOG_TIMEOUT_ms,
                                             BSP_WDOG_CLK_FREQ,
                                             BSP_WDOG_TIMER_PRESC);
    RTWDOG_Init(BSP_WDOG_TIMER, &wdogConfig); //The stuck problem happens here.
}

//In file main.c

/**
*
* @brief This function is called in SystemInit()at system_MIMXRT1052.c
* and is to be used to init things close to reset.
*
*/
void SystemInitHook (void)
{
    wdog_Init();
}

 


Probably i am doing something wrong, but was not able to figure it out. Can you help me?

 

Thanks,

João Paulo

0 Kudos
Reply
1 Reply

605 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @jpgoncalves ,

  Do you test the SDK code watchdog example directly?

SDK_2_10_0_EVKB-IMXRT1050\boards\evkbimxrt1050\driver_examples\rtwdog

Whether this code can works OK on your side or not?

Your SDK is old, please use the newest SDK project and test it, you can download the newest SDK code from this link:

https://mcuxpresso.nxp.com/

Best Regards,

Kerry

0 Kudos
Reply