;********************************************************************* ; * ; PIC16C5X Tutorial 5: Watch Dog Reset Timer with Prescalor * ; * ;********************************************************************* ;* TARGET PIC16C5X ;********************************************************************* ;* @version 0.1, 10 October 2001 ;* @author James Caska ;********************************************************************* ;* ;* Runs on Processors without change ;* ;* PIC16c54 ;* PIC16c55 ;* PIC16c56 ;* PIC16c57 ;* ;********************************************************************* #include list p=16C54 DELAYCOUNTER EQU .8 ORG .0 ;========================================== ;Autogenerated configuration code PIC16C5X ;Config Wiz V0.1, www.virtualbreadboard.com ;========================================== ;======Begin PORT Configuration ;======PORT B MOVLW .0 ;PORTB Configuration Bits TRIS PORTB CLRF PORTB BTFSS STATUS,NOT_PD GOTO WDT.TimeOut GOTO WDT.Sleep Delay1msapprox MOVLW .255 MOVWF DELAYCOUNTER Delay1msapprox.loop NOP DECFSZ DELAYCOUNTER,F GOTO Delay1msapprox.loop RETLW .0 WDT.TimeOut ;========================================== ;Autogenerated configuration code PIC16C5X ;Config Wiz V0.1, www.virtualbreadboard.com ;========================================== ;======Begin Timer0 Configuration ;Timer0 Timer Mode, uses Internal clock ;Prescalor Assigned to Watchdog, Timer0 Prescalor = 1:1, WDT Prescalor = 1:2 MOVLW .9 OPTION ;======End Timer0 Configuration WDT.TimeOut.doInc CALL Delay1msapprox ;Increment every ms approx INCF PORTB,F ;Should reach about 36(ms) at 1:2 prescalor before timingout GOTO WDT.TimeOut.doInc WDT.Sleep ;========================================== ;Autogenerated configuration code PIC16C5X ;Config Wiz V0.1, www.virtualbreadboard.com ;========================================== ;======Begin Timer0 Configuration ;Timer0 Timer Mode, uses Internal clock ;Prescalor Assigned Timer0, Timer0 Prescalor = 1:2 , Watchdog prescalor 1:1 MOVLW .0 OPTION ;======End Timer0 Configuration MOVLW .255 MOVWF PORTB ;Write PORTB to switch all Pins on SLEEP ;Sleeps now until Watch Dog Timeout END