LPC4357 watchdog unable to reset the mcu

cancel
Showing results for 
Search instead for 
Did you mean: 

LPC4357 watchdog unable to reset the mcu

1,432 Views
uaz
Contributor II

Hi,

I'm having a problem with my watchdog, where it fails to reset the mcu (custom board) after watchdog timer times out. The mcu will stall instead of resetting. I'm running a slightly modified version of LPCopen watchdog example (removed semihosting and let the mcu to watchdog reset after several seconds running).

I ran the same watchdog example code on lpcxpresso4367, but the mcu managed to reset successfully. Now I'm suspecting hardware problem but I have no idea where.

Is there any particular circuit or setting needed for the watchdog to work correctly?

Or is there defective batch of LPC4357JBD208 chip?

Thanks,

UAZ

Labels (1)
0 Kudos
11 Replies

1,012 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi uaz 

For LPC4357, The WWDT is not operating in Deep-sleep, Power-down, and Deep power-down modes.

If you don't use these modes, but still have problem, please let me know which demo code you are using and where you modified. Thanks


Have a great day,
Jun Zhang

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

1,012 Views
uaz
Contributor II

It is running in normal mode. When watchdog times out, the mcu will freeze (application stopped running) instead of resetting.

Here is the modified sample code from lpcopen_3_02_lpcxpresso_mcb4357 (nohost):

/*
 * @brief WWDT example
 *
 * @note
 * Copyright(C) NXP Semiconductors, 2013
 * All rights reserved.
 *
 * @par
 * Software that is described herein is for illustrative purposes only
 * which provides customers with programming information regarding the
 * LPC products.  This software is supplied "AS IS" without any warranties of
 * any kind, and NXP Semiconductors and its licensor disclaim any and
 * all warranties, express or implied, including all implied warranties of
 * merchantability, fitness for a particular purpose and non-infringement of
 * intellectual property rights.  NXP Semiconductors assumes no responsibility
 * or liability for the use of the software, conveys no license or rights under any
 * patent, copyright, mask work right, or any other intellectual property rights in
 * or to any products. NXP Semiconductors reserves the right to make changes
 * in the software without notification. NXP Semiconductors also makes no
 * representation or warranty that such application will be suitable for the
 * specified use without further testing or modification.
 *
 * @par
 * Permission to use, copy, modify, and distribute this software and its
 * documentation is hereby granted, under NXP Semiconductors' and its
 * licensor's relevant copyrights in the software, without fee, provided that it
 * is used in conjunction with NXP Semiconductors microcontrollers.  This
 * copyright, permission, and disclaimer notice must appear in all copies of
 * this code.
 */

#include "board.h"

/*****************************************************************************
 * Private types/enumerations/variables
 ****************************************************************************/

static volatile int wdtFeedState;
static volatile bool On = false, On1 = false;

/*****************************************************************************
 * Public types/enumerations/variables
 ****************************************************************************/

/*****************************************************************************
 * Private functions
 ****************************************************************************/

/* WDT interrupt handler */
static void wdt_handle(void) {
 uint32_t wdtStatus = Chip_WWDT_GetStatus(LPC_WWDT);

 On = (bool) !On;

 /* The chip will reset before this happens, but if the WDT doesn't
    have WWDT_WDMOD_WDRESET enabled, this will hit once */
 if (wdtStatus & WWDT_WDMOD_WDTOF) {
  /* A watchdog feed didn't occur prior to window timeout */
  Chip_WWDT_ClearStatusFlag(LPC_WWDT, WWDT_WDMOD_WDTOF);

  if (wdtFeedState == 2) {
   Chip_WWDT_Start(LPC_WWDT); /* Needs restart */
  }
 }

 /* Handle warning interrupt */
 if (wdtStatus & WWDT_WDMOD_WDINT) {
  /* A watchdog feed didn't occur prior to warning timeout */
  Chip_WWDT_ClearStatusFlag(LPC_WWDT, WWDT_WDMOD_WDINT);

  if (wdtFeedState == 1) {
   Chip_WWDT_Feed(LPC_WWDT);
  }
 }
}

/*****************************************************************************
 * Public functions
 ****************************************************************************/

/**
 * @brief Event router Interrupt Handler
 * @return Nothing
 * Handles event router events
 */
void EVRT_IRQHandler(void)
{
 On1 = !On1;

 /* Clear watchdog timer interrupt in event router (ok to clear before
    watchdog clear on edge based event router events) */
 Chip_EVRT_ClrPendIntSrc(EVRT_SRC_WWDT);

 wdt_handle();
}

/**
 * @brief watchdog timer Interrupt Handler
 * @return Nothing
 * @note Handles watchdog timer warning and timeout events
 */
void WDT_IRQHandler(void)
{
 wdt_handle();
}

/**
 * @brief SysTick Interrupt Handler
 * @return Nothing
 * @note Systick interrupt handler feeds WWDT
 */
void SysTick_Handler(void)
{
 if (wdtFeedState == 0) {
  //On = (bool) !On;
  Chip_WWDT_Feed(LPC_WWDT);
 }

 On = (bool) !On;
}

/**
 * @brief Main entry point
 * @return Nothing
 */
int main(void)
{
 uint8_t ch;

 SystemCoreClockUpdate();
 Board_Init();

 /* Watchdog will be fed on each watchdog interrupt */
 wdtFeedState = 0;

 /* Initialize WWDT and event router */
 Chip_WWDT_Init(LPC_WWDT);
 Chip_EVRT_Init();

 /* Set watchdog feed time constant to 0.1s
    Set watchdog warning time to 512 ticks after feed time constant
    Set watchdog window time to 0.9s */
 Chip_WWDT_SetTimeOut(LPC_WWDT, WDT_OSC / 10);
 Chip_WWDT_SetWarning(LPC_WWDT, 512);
 Chip_WWDT_SetWindow(LPC_WWDT, WDT_OSC - (WDT_OSC / 10));

 /* Configure WWDT to reset on timeout */
 Chip_WWDT_SetOption(LPC_WWDT, WWDT_WDMOD_WDRESET);

 /* Clear watchdog warning and timeout interrupts */
 Chip_WWDT_ClearStatusFlag(LPC_WWDT, WWDT_WDMOD_WDTOF | WWDT_WDMOD_WDINT);

 /* Initiate EVRT, route interrupt signal from WWDT to EVRT,
    enable EVRT WWDT interrupt */
 Chip_EVRT_ConfigIntSrcActiveType(EVRT_SRC_WWDT, EVRT_SRC_ACTIVE_RISING_EDGE);
 Chip_EVRT_SetUpIntSrc(EVRT_SRC_WWDT, ENABLE);

 /* Start watchdog */
 Chip_WWDT_Start(LPC_WWDT);

 /* Setup Systick for a 10Hz tick rate. Systick clock is clocked at
    CPU core clock speed */
 SysTick_Config(Chip_Clock_GetRate(CLK_MX_MXCORE) / 20);

 /* Enable watchdog interrupt */
 NVIC_EnableIRQ(WWDT_IRQn);

 /* Watchdog test options */
 DEBUGOUT("Press '1' to enable watchdog feed on systick interrupt\n\r");
 DEBUGOUT("Press '2' to enable watchdog feed on warning interrupt\n\r");
 DEBUGOUT("Press '3' to disable watchdog feed (will reset device)\n\r");
 DEBUGOUT("Press '4' to switch from WDT interrupt to event router handler\n\r");

 CPU_LED_SEL;
 STAT_LED_SEL;
 RUN_LED_SEL;

 CPU_LED_DIR;
 STAT_LED_DIR;
 RUN_LED_DIR;

#define DELAY_COUNT 208000000/4
    unsigned long count1 = 0;

    Board_LED_Set(0, true);
 count1 = DELAY_COUNT;
 while (count1--);
 Board_LED_Set(0, false);
 count1 = DELAY_COUNT;
 while (count1--);
 Board_LED_Set(0, true);
 count1 = DELAY_COUNT;
 while (count1--);
 Board_LED_Set(0, false);
 count1 = DELAY_COUNT;
 while (count1--);
 Board_LED_Set(0, true);
 count1 = DELAY_COUNT;
 while (count1--);
 Board_LED_Set(0, false);
 count1 = DELAY_COUNT;
 while (count1--);

    while (1) {

        // Do fast blink for several seconds
        count1 = DELAY_COUNT/4;
        do {
   Board_LED_Set(0, On);
   Board_LED_Set(1, On1);
  } while (count1--);

        // Change watchdog option
        wdtFeedState = 2;

        // Continue fast blink
        do {
            ch = (uint8_t) DEBUGIN();
            //fflush(stdin);
            //scanf ("%d", &ch);
            Board_LED_Set(0, On);
   Board_LED_Set(1, On1);
        } while ((ch < '1') || (ch > '4'));

  switch (ch) {
  case '1':
  default:
   wdtFeedState = 0;
   DEBUGOUT("Watchdog feed on systick interrupt\r\n");
   break;

  case '2':
   wdtFeedState = 1;
   DEBUGOUT("Watchdog feed on warning interrupt\r\n");
   break;

  case '3':
   wdtFeedState = 2;
   DEBUGOUT("No feeding - board will reset\r\n");
   break;

  case '4':
   DEBUGOUT("using event router instead of WDT interrupt\r\n");
   NVIC_DisableIRQ(WWDT_IRQn);
   NVIC_EnableIRQ(EVENTROUTER_IRQn);
   break;
  }
 }
}
0 Kudos

1,012 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi

This is lpcopen packages,

LPCOpen Software for LPC43XX | NXP 

please let me know which package you are using, and how to modify the demo to reproduce your problem

0 Kudos

1,012 Views
uaz
Contributor II

Hi,

I am using "lpcopen_3_02_lpcxpresso_mcb4357". I modified the pinmuxing in board_sysinit.c to match my own board. The program is modified as in my previous post.

I found the issue:

My external memories is using P2_7 as EMC_A9  (function 3). I believe when watchdog reset occurs, it will accidentally enter ISP mode, thus explaining the mcu hang. I tested with 10k pull up, but the problem still persists.

I have tested and confirmed that lpcxpresso4367 dev board also had this issue if I use P2_7 as EMC_A9.

Is there workaround to this problem?

Thanks

0 Kudos

1,012 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

I wonder your P2_7 is pull low during reset, thus your chip goes to ISP mode using USART0.

please refer this solution of how to solve this problem:

How to config LPC1850 ISP pin (P2_7) from EMC A9 


Have a great day,
Jun Zhang

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

1,012 Views
uaz
Contributor II

Hi,

Effectively, P2_7 is pulled low when EMC_A9 function is selected.

When a watchdog reset happens, I believe the pin stays pulled low.

I have verified this issue with my own board and also your OM13088 board (both having a pull up resistor on P2_7).

You can try run a watchdog reset with P2_7 configured as EMC_A9.

To solve this issue, I need to select P2_7 as GPIO. But this is not possible since I'm using external memories on my board. Any other solution?

Thanks

0 Kudos

1,012 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

It is recommended to provide external hardware (a pull-up resistor or other device) to put the P2_7 pin in a defined state.

LPC43xx has WWDT warning interrupt, user can config its concrete trigger time before watchdog reset happens. You can try to force P2_7 as GPIO high in WWDT warning interrupt. WARNINT is to configure watchdog warning interrupt compare value.


Have a great day,
Jun Zhang

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

1,012 Views
uaz
Contributor II

hi ZhangJennie‌,

My custom board and OM13088 do have external pull up on P2_7 pin but the problem still persists when EMC_A9 function is selected.

I have tried using WWDT warning interrupt to switch the pin back to GPIO. In order for this to work, the smallest value of WARINT that I can use is 6 . This means there is a risk of writing or reading data to/from wrong address (after changing P2_7 to GPIO) between WWDT warning and and WWDTtimeout.

A way to prevent the above risk is by blocking inside WWDT warning interrupt until WWDT timeout happens. This, however, defeats the purpose of having WWDT warning interrupt since we are using it as a 'timeout'.

I wonder if there is a less hacky way to use both WWDT and EMC together.

0 Kudos

1,012 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

HI uaz,

I just discussed your issue internally, if no change on hardware, there is no other easy solutions.

Jun Zhang

0 Kudos

1,012 Views
uaz
Contributor II

Hi ZhangJennie‌,

May I know the hardware change solution that you discussed with your colleagues? I might be able to implement it in my next pcb version.

Thanks,

UAZ

0 Kudos

1,012 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

HI uaz,

If you won't mind change HW, I suggest you use external HW watchdog chip rather than SW watchdog.

Sure a pull up resistor on P2_7 is necessary,


Have a great day,
Jun Zhang

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos