WDT Reconfigure

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

WDT Reconfigure

Jump to solution
1,238 Views
Robinwithu
Senior Contributor I

Hi All,

 

I am Trying to reconfigure WDT but it's not working properly for µC MC9S08RN8  please can someone see my code?

 

void main {

WDOG_CNT = 0xC520;                                    // write the 1st unlock word

WDOG_CNT = 0xD928;                                    // write the 2nd unlock word

WDOG_TOVAL = 4;                                         // setting timeout value

WDOG_CS2 = 0X12;                                        //Prescaler is selected for 256 and 32Khz clock

 

__RESET_WATCHDOG();

 

PORT_PTAOE = 0x0F;

PORT_PTAD =  0x00;

while(1) {

PORT_PTAD =  0x0F;

}

 

}

 

According to new configuration i should get 31.25msec WDT RESET but the reset i am getting is  7 msec which is Default value of   WDT RESET.

 

I also tried  using WDOG_CS1_UPDATE register but after updating that register i am not getting any reset.

 

I am using Codewarrior 10.5 and PE Micro USBMultilink interface for programming.

 

 

Thanks and Kind Regards

 

Robin

Labels (1)
1 Solution
764 Views
ankur_kala
NXP Employee
NXP Employee

Hi Robin,

please keep in mind that to use 32KHz source, you would need to enable ICS_C1[IRCLKEN]. Hope this solves your issue.

BR,

Ankur

View solution in original post

12 Replies
764 Views
ankur_kala
NXP Employee
NXP Employee

Hi Robin,

you can check the following thread: Watchdog enables itself after reset

0 Kudos
764 Views
Robinwithu
Senior Contributor I

AnkurGandhi

Hello Ankur,

I tried the above code but for me it's not working .please can you see that code

void main {

WDOG_CNT     = 0xC520;

WDOG_CNT     = 0xD928;

WDOG_CS1     = 0x20;                                // Update WDT value

WDOG_CS2     = 0x12;                              // Prescale 256 selected n WDT Freq. 32768

WDOG_TOVAL  = 0x0A;

   PORT_PTAOE = 0x0F;

        PORT_PTAD =  0x00;

        delay(200);

__RESET_WATCHDOG();

        while(1){

     

            PORT_PTAD =  0x0F;

         

        }

}

i am not getting any reset , i PortA pin  is always high.

i am using MC9S08RN8 controller , CW10.5 n PE USB multilink Programmer.

Thanks n BR

Robin

0 Kudos
764 Views
ankur_kala
NXP Employee
NXP Employee

Hi Robin,

I just realized that you are overwriting the WDOG_CS1 register with a value 0x20, which would effectively disable the watchdog as the enable bit would be set to 0 (i.e., unless I am missing out on certain section that you have not shown in the above chain).

0 Kudos
764 Views
Robinwithu
Senior Contributor I

Hi Ankur,

Now the code is working fine but the only problem what i am facing is it's not selecting 32Khz Frequency ,for 1khz and Bus frequency it works fine here is code what i modified .

One more thing i didn't updated WDOG_CS1_UPDATE register but the code is working fine.Please can you see the code why it's not working for 32Khz Frequency?

void main {

WDOG_CNT     = 0xC520;

  WDOG_CNT     = 0xD928;

WDOG_TOVAL = 10;

WDOG_CS2     = 0x11;

WDOG_CS1     = 0x80;

__RESET_WATCHDOG();

PORT_PTAOE = 0x0F;

        PORT_PTAD =  0x00;

        delay(200);

  while(1){

  

            PORT_PTAD =  0x0F;

      

        }

}

Thanks n KR

Robin

0 Kudos
765 Views
ankur_kala
NXP Employee
NXP Employee

Hi Robin,

please keep in mind that to use 32KHz source, you would need to enable ICS_C1[IRCLKEN]. Hope this solves your issue.

BR,

Ankur

764 Views
Robinwithu
Senior Contributor I

Hi Ankur,

Thanks a lot it works fine after Enabling the Reference frequency in ICS_C1[IRCLKEN] Register.

Here is the Working code if someone  needs :smileyhappy:

void main {

ICS_C1 = 0x06;                              // FEI Mode and Internal  Refrence Clock Enabled [IRCLKEN]

WDOG_CNT     = 0xC520;

WDOG_CNT     = 0xD928;

WDOG_TOVAL = 10;

WDOG_CS2     = 0x12;                    // Prescaler selected and 32Khz Clock for WDT

WDOG_CS1     = 0x80;                    // Feed the Dog

__RESET_WATCHDOG();

PORT_PTAOE = 0x0F;

PORT_PTAD =  0x00;

delay(10);

  while(1){

  

            PORT_PTAD =  0x0F;

      

        }

}

Thanks a lot once again.

Kind Regards,

Robin

0 Kudos
764 Views
ankur_kala
NXP Employee
NXP Employee

Hi Robin,

Great to see that finally everything working for you.

Please feel free to mark the answers helpful/correct as you see them.

Regards,

Ankur

0 Kudos
764 Views
Robinwithu
Senior Contributor I

Hi Ankur,

Thanks i will do the changes n let you know.

Regards,

Robin

0 Kudos
764 Views
ankur_kala
NXP Employee
NXP Employee

Hi Robin,

a couple of questions for a better insight:

1) What is the unit of delay(200) function? Is it in the order of msecs or secs.

2) how are you observing PORTA pin? Is there a possibility that the time for which portA pin goes low is small enough to be missed by a multimeter or even in a Oscilloscope if not properly triggered.

3) are you able to seemlessly debug the code on your hardware?

0 Kudos
764 Views
Robinwithu
Senior Contributor I

Hi Ankur,

1) it's in µsec , cause cpu is operating at 20Mhz. (appx. 10µsec)

2) I am observing it on oscilloscope , their is no possibility that it will miss the toggling of Port pin.

3) I am not debugging it but i did it before and i don't have any problem with debugging.

Thanks

BR

Robin

0 Kudos
764 Views
ankur_kala
NXP Employee
NXP Employee

OK. Just give me some time to find a hardware to debug.

0 Kudos
764 Views
Robinwithu
Senior Contributor I

Thanks Ankur.

Kind Regards,

Robin

0 Kudos