 
					
				
		
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
Solved! Go to Solution.
 ankur_kala
		
			ankur_kala
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		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
 ankur_kala
		
			ankur_kala
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hi Robin,
you can check the following thread: Watchdog enables itself after reset
 
					
				
		
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
 ankur_kala
		
			ankur_kala
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		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).
 
					
				
		
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
 ankur_kala
		
			ankur_kala
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		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
 
					
				
		
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
 ankur_kala
		
			ankur_kala
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		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
 
					
				
		
Hi Ankur,
Thanks i will do the changes n let you know.
Regards,
Robin
 ankur_kala
		
			ankur_kala
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		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?
 
					
				
		
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
 ankur_kala
		
			ankur_kala
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		OK. Just give me some time to find a hardware to debug.
 
					
				
		
Thanks Ankur.
Kind Regards,
Robin
