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)
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