I'm using Philips P89C664 which includes watchdog timer on the PCA Module 4. P89C664 is running with 10.000MHz oscillator in 6 clock mode. I use µVision V2.40 with C51 V7.09. In Power-Up Initialization PCA is configured as follows:
CMOD = 0x02; //PCA Input Internal clock, fOSC/2 in 6 clock mode. CCAP2H = 0x80; //PWM mit 50%/50% Duty cycle. CCAPM2 = 0x42; //Activate PCA Module 2 with PWM-Output on CEX2 (P1.5) -> PWM with approx. 19.5 kHz. CCON = 0x40; //PCA Counter Run. CCAPM4 = 0x08; //Activate PCA Module 4 with Watchdog Timer, period approx. 13.2ms. CCAP4L = 0xFF; //With clearing the bit ECOM4 (Disabling comparator in PCA Module 4). CCAP4H = 0xFF; //With setting the bit ECOM4 (Enabling comparator in PCA Module 4). CMOD |= 0x40; //Setting bit Watchdog Timer Enable. Bios_delay_250ms();
; FUNCTION Bios_delay_5ms (BEGIN) ;---- Variable 'uc_ticks1' assigned to Register 'R7' ---- 0000 7F33 MOV R7,#033H ;---- Variable 'uc_ticks2' assigned to Register 'R6' ---- 0002 7E11 MOV R6,#011H 0004 ?C0004: 0004 DFFE DJNZ R7,?C0004 0006 DEFC DJNZ R6,?C0004 0008 22 RET ; FUNCTION Bios_delay_5ms (END) ; FUNCTION Bios_delay_250ms (BEGIN) ;---- Variable 'uc_hilfsvar' assigned to Register 'R5' ---- 0000 7D32 MOV R5,#032H 0002 ?C0010: 0002 120000 R LCALL Bios_delay_5ms 0005 E4 CLR A 0006 F5EE MOV CCAP4L,A 0008 85F9FE MOV CCAP4H,CH <--- Simulator Breakpoint here 000B DDF5 DJNZ R5,?C0010 000D 22 RET ; FUNCTION Bios_delay_250ms (END)
Erik, are you a member of the KEIL support team my postings at http://www.keil.com/forum/docs/thread6246.asp (the IDE is stupid) should answer that. Erik
Hi devs, i get a new bugfixed version of Simulator-DLL (DP51.DLL Version 2.46b)! Now my Code works fine on it, thanks to KEIL support team! Martin
i have problems using the watchdog timer because of the very short delay befor reset could you helpe me to make the delay longer and please send me assembly software for philips p89c668 microcomputer to make the wd work thankyou m. kattan
Hi Mohamed, the hardware Watchdog-Timer (WDT) has only a 14-bit prescaler, so if you use 18.432 MHz crystal you get a WDT period of approx. 5.333 ms (Milliseconds). There is no way to extend the WDT delay. Except slowering the crystal clock itself of course ;-) You can use alternatively the Watchdog function of the PCA. But this isn't a true Watchdog function because in case of software malfunction the PCA can be stopped or cleared unintentionally, so the PCA-Watchdog is no more able to reset the µC! (see the topics above) So the only (relative) safe way you have is to retrigger the WDT by timer interrupt! BUT: Don't retrigger the WDT by timer interrupt ONLY! Because if a routine in mainloop hangs, Wtchdog will not reset the µC due to retriggering WDT permanently by timer interrupt! In this case, it's heavly recommended to extend your code by interprocess communication (e.g. semaphore or simply a bit flag), so the mainloop (which period is normally larger than timer interrupt interval) "can tell" to timer interrupt, "i'm okay"! If this flag fails, timer interrupt stopps retrigerring the WDT. Hope this helps you? Martin
please send me assembly software for philips p89c668 microcomputer to make the wd work Rephrase: please help me avoid the tedious task of reading the datasheet the hardware Watchdog-Timer (WDT) has only a 14-bit prescaler, so if you use 18.432 MHz crystal you get a WDT period of approx. 5.333 ms (Milliseconds). There is no way to extend the WDT delay. Except slowering the crystal clock itself slowing the clock gain you NOTHING. The number of instructons executed between WD ticks is a constant. So the only relative safe way you have is to retrigger the WDT by timer interrupt! This method has the same shortcoming as the PCA4 method, it can be beaten by runaway software. I never have understood the issue of this WD, you get 16000 instruction cycles per WD tick where is the problem? Retriggereing the WD once per 16000 instruction cycles is, if anything, too infrequent. Erik
you get 16000 instruction cycles per WD tick where is the problem? In my case, the mainloop (this is the endless loop in main() written in c language) will be computed every 20ms, in some other projects 100ms. Due to floating-point algorithms (with trigonometric functions) some unoptimized subroutines lasts up to 200ms, e.g. calculating solar state. With these outputs we can control the slat tracking on venetian blinds (sun protection) depending of the sun in geographical relation to the facade (azimuth and heigth). I have been optimized these number-cruncher subroutines down to 16ms (time-sliced). So its impossible to fit the whole mainloop into the WDT period of 5.33ms. This is a example where mainloop period is normally larger than timer interrupt interval. Martin BTW: In older projects e.g. with Infineon SABC515C there is a WDT with configurable periods of 1sec or longer at 10MHz, we have no problems with WDT intervals in mainloop with 100ms periods.
Sorry, This is a example where mainloop period is normally larger than timer interrupt interval. must be corrected as: This is a example where mainloop period is normally larger than WDT interval. Martin
This is a example where mainloop period is normally larger than timer interrupt interval. Who on earth has stated that you can only kick the puppy once in the main loop? floating-point algorithms (with trigonometric functions) .... (time-sliced). Martin, How often do you wipe the little '51s forehead, you are making it work really hard. It sounds as if you have coded "for the convenience of the programmer" not "for the convenience of the chip" Erik