Unable to write to COP

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

Unable to write to COP

Jump to solution
960 Views
umlengineer
Contributor I

Hi,

I am trying to implement a watchdog timer in my code, and I think the register is being addressed before I use the init function, but I can not find where.  I was able to find the disable in the system_MKL17Z644.h file:

#ifndef DISABLE_WDOG
  #define DISABLE_WDOG  0
#endif

However when I set the define to 0 I get a working watchdog timer, but not with the settings that I am sending.  I am trying to set the debug bit, and the long timeout bits as I would like as long of a timeout as I can set to start with, but when I read the register after I write to it, I only see that COPT has been set to 11, all other bits are 0.  This is read through a PE Micro debugger. 

For reference, here is a sample of what i cam doing to enable the COP, my actual code is way to big to just paste in. 

#include "fsl_cop.h"
#include "fsl_rcm.h"

cop_config_t configCop;

COP_GetDefaultConfig(&configCop);  //Here is where I setup the long delay and debug bits

COP_Init(SIM, &configCop);

No matter when I check the register, I see the same settings, that is at the top of main, right before and right after the init(). 

Does anyone have any ideas as to what I am doing wrong?

Thanks!

0 Kudos
1 Solution
825 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello Evan Griffith

 

I agree with you, DISABLE_WDOG must be zero in order to get a functional cop. To do this please disable it from the Preprocessor macros at: properties- > C/C++ Build -> Settings -> MCU C Compiler -> Preprocessor

pastedImage_2.png

 

Please check that the macro FSL_FEATURE_COP_HAS_LONGTIME_MODE is defined with one if this macro is not defined to 1 the value loaded to the COP registers may vary from your desired values.

 

Let me know if this is helpful, if you have more questions do not hesitate to ask me.

Best Regards,

View solution in original post

0 Kudos
4 Replies
825 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello Evan Griffith

 

Based on the sdk example I suggest you set the macro DISABLE_WDOG to 1. Also please check that the macro FSL_FEATURE_COP_HAS_LONGTIME_MODE is 1. Those 2 macros are very important for the COP init. You can find these macros at "MKL17644_features.h"

 pastedImage_1.png

 

Regarding your sample code it is well defined, in the example we make a verification before init the cop:

 

    cop_config_t configCop;

    COP_GetDefaultConfig(&configCop);

 

    /* Check if WDOG reset occurred */

    if (RCM_GetPreviousResetSources(RCM) & kRCM_SourceWdog)

    {

        PRINTF("Reset due to COP timeout\r\n");

        COP_Disable(SIM);

        PRINTF("COP example ends!\r\n");

    }

    else

    {

        /* If WDOG reset is not occurred, enables COP */

        PRINTF("\r\nCOP example start!\r\n");

        COP_Init(SIM, &configCop);

 

After this, you can call the function COP_Refresh() to feed the dog.

 

Let me know if this is helpful, if you have more questions do not hesitate to ask me.

Best regards,

Omar

0 Kudos
825 Views
umlengineer
Contributor I

Hi,

Thanks for getting back to me, but I am still confused.  If I disable the COP in the system_MKL17Z644, it runs this line of code I think: 

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

Won't this address the timer and make it so that I can not use it?  I only ask because when I do set DISABLE_WDOG to 1 and go to init the COP I get a non functional COP.

The configuration from get default config looks correct:

pastedImage_1.png

However the Init does not change the register values:

pastedImage_2.png

I will keep digging into it, but I am a bit lost.

Thanks!

0 Kudos
826 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello Evan Griffith

 

I agree with you, DISABLE_WDOG must be zero in order to get a functional cop. To do this please disable it from the Preprocessor macros at: properties- > C/C++ Build -> Settings -> MCU C Compiler -> Preprocessor

pastedImage_2.png

 

Please check that the macro FSL_FEATURE_COP_HAS_LONGTIME_MODE is defined with one if this macro is not defined to 1 the value loaded to the COP registers may vary from your desired values.

 

Let me know if this is helpful, if you have more questions do not hesitate to ask me.

Best Regards,

0 Kudos
825 Views
umlengineer
Contributor I

Hi,

I did not see that line for the watchdog in the settings so I wrote it in, but it solved all of my issues.  I guess commenting out the line in code is not the same :smileyhappy:. 

Thanks for all your help!

0 Kudos