~aleteoryx/muditaos

1e496a8fd71a0284811be8b52843c28076f00c8e — Lefucjusz 2 years ago 1d51c5c
[BH-1833] Fix debug after watchdog config change

Fix of the issue that waiting for RTWDOG
unlock bit to be set after issuing unlock
command caused the debug to crash
immediately after the OS started.
1 files changed, 8 insertions(+), 8 deletions(-)

M module-bsp/board/rt1051/common/system_MIMXRT1051.c
M module-bsp/board/rt1051/common/system_MIMXRT1051.c => module-bsp/board/rt1051/common/system_MIMXRT1051.c +8 -8
@@ 109,20 109,20 @@ void SystemInit(void)
    }

    /* Perform preliminary RTWDOG configuration */
    /* Write RTWDOG update key to unlock */
    if ((RTWDOG->CS & RTWDOG_CS_CMD32EN_MASK) != 0) {
        RTWDOG->CNT = 0xD928C520U;
    }
    else {
        RTWDOG->CNT = 0xC520;
        RTWDOG->CNT = 0xD928;
    }
#if defined(DISABLE_WATCHDOG)
    /* Write RTWDOG update key to unlock and wait for unlocking */
    RTWDOG->CNT = 0xD928C520U;
    while ((RTWDOG->CS & RTWDOG_CS_ULK_MASK) == 0) {}

    /* Disable RTWDOG and allow configuration updates, wait until config is applied */
    RTWDOG->TOVAL = 0xFFFF;
    RTWDOG->CS    = ((RTWDOG->CS & ~RTWDOG_CS_EN_MASK) | RTWDOG_CS_UPDATE_MASK);
    while ((RTWDOG->CS & RTWDOG_CS_RCS_MASK) == 0) {}
#else
    /* Write RTWDOG update key to unlock and wait for unlocking */
    RTWDOG->CNT = 0xD928C520U;
    while ((RTWDOG->CS & RTWDOG_CS_ULK_MASK) == 0) {}

    /* Set timeout value to 16s (assuming 128Hz clock - 32.768kHz from LPO_CLK, with 256 prescaler) */
    RTWDOG->TOVAL = 16 * 128;