MKW31Z512 and SDK2.2.1 - Watchdog (COP) doesn't work

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

MKW31Z512 and SDK2.2.1 - Watchdog (COP) doesn't work

Jump to solution
1,062 Views
giuliano_errico
Contributor II

Hi all,

I am working on a project that uses the micro MKW31Z512 and I am having some problems with the watchdog (COP module). When I started, I used the SDK 2.2.0. The board had to use the bootloader and in the code, I found some instructions that disabled the watchdog. I removed them and added the enablement of it in the main application. Everything worked well. Then I was asked to migrate to the newer SDK 2.2.1 but I encountered some problems, because the watchdog doesn't work. I removed the same instructions in the bootloader project, thinking that it was enough, but I still can't reset the MCU. I can't find any other instructions about the COP so, can anyone tell me if there are any other instructions to remove/add in order to make it work? I'm using IAR Embedded Workbench for ARM 8.32.1.

Here is the code (used in both projects, with SDK 2.2.0 and 2.2.1):

BOOTLOADER (the part of the code that i removed):

#if defined(CPU_MKW24D512VHA5) || defined(MCU_MK21DX256) || defined(CPU_MK64FN1M0VLL12)
      WDOG->UNLOCK = 0xC520;
      WDOG->UNLOCK = 0xD928;
      WDOG->STCTRLH &= ~WDOG_STCTRLH_WDOGEN_MASK;
#elif defined(CPU_MKL46Z256VLL4) || defined(MCU_MKW40Z160) || defined(CPU_MKW41Z512VHT4)
      SIM->COPC = SIM_COPC_COPT(0);
#endif

MAIN APPLICATION (my configuration):

      cop_config_t cop_config;
      cop_config.enableWindowMode = false;
#if FSL_FEATURE_COP_HAS_LONGTIME_MODE
      cop_config.timeoutMode = kCOP_ShortTimeoutMode; //Derived from SDK1.3
      //cop_config.timeoutMode = kCOP_LongTimeoutMode;

      cop_config.enableStop = false;
      cop_config.enableDebug = true;
#endif
      cop_config.clockSource = kCOP_LpoClock;
      cop_config.timeoutCycles = kCOP_2Power10CyclesOr2Power18Cycles;
      COP_Init(SIM, &cop_config);

Another question (less important): In the previous SDK (2.2.0), the watchdog works only when the debug is not running, even if the flag (cop_config.enableDebug = true;) is set. Is there anything else to configure?

Thank you in advance!

Tags (1)
0 Kudos
Reply
1 Solution
949 Views
giuliano_errico
Contributor II

Ok, I found the reason!! In the file system_MKW41Z4.c there is another instruction that disables the watchdog again!

#if (DISABLE_WDOG)
   /* SIM_COPC: COPT=0,COPCLKS=0,COPW=0 */
   SIM->COPC = (uint32_t)0x00u;
#endif /* (DISABLE_WDOG) */

I removed the instruction and now the watchdog works as it should!

I didn't find it before because the first version of the project has been done by a colleague of mine and she didn't tell me about that instruction!! :smileyhappy:


View solution in original post

0 Kudos
Reply
2 Replies
950 Views
giuliano_errico
Contributor II

Ok, I found the reason!! In the file system_MKW41Z4.c there is another instruction that disables the watchdog again!

#if (DISABLE_WDOG)
   /* SIM_COPC: COPT=0,COPCLKS=0,COPW=0 */
   SIM->COPC = (uint32_t)0x00u;
#endif /* (DISABLE_WDOG) */

I removed the instruction and now the watchdog works as it should!

I didn't find it before because the first version of the project has been done by a colleague of mine and she didn't tell me about that instruction!! :smileyhappy:


0 Kudos
Reply
949 Views
Sebastian_Del_Rio
NXP Employee
NXP Employee

Hi Giuliano, I hope you're doing well!

 

It's good to know you got the watchdog working!

 

Please let us know if you have any further issues.

 

Best regards,

Sebastian

0 Kudos
Reply