Searching \ for '[PIC]:FastReset rev 2' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page:
Search entire site for: 'FastReset rev 2'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]:FastReset rev 2'
2000\11\17@174326 by Morgan Olsson

picon face
part 1 1379 bytes content-type:text/plain; charset="us-ascii"Improvement to first revision is this is not depending on any pin use.
(the earlier version had a dependancy upon PA4)

I have implemented the suggestion of Simon Nield, that makes it insensitive of the level and use of Porta pin 4 by sensing, adapting, and then retries if RA4 changed and made it fail this time.

To top it off, it is now failsafe even if PA4 has some signal/noise of a frequency that makes even the x number of retries fail and then reverts to just waiting for normal Watchdog reset at shortest prescaler.

Monitor code using port E is included, and performed testing described.

And yes, there really is some code amongst the comments...

It would be nice if somebody tries this on another PIC than the F877 it is now tested on, and reports if it works or not, as the chip function it uses is not completely described in PIC documentation.
(also send me corrections if my english is wrong or there is some typo or whatever)

It should be safe to use anyhow due to that it reverts to normal Wdog timeout usage if it fails to assert direct reset.

If it has no problem, then I suggest it be placed in the archive
somewhere... -How?

I would like to thank Simon Neild for suggestions and discussion, and Bob Ammerman for positive replies.

Enjoy!     :)

part 2 5402 bytes content-type:text/plain; charset="us-ascii"
       messg "  * FAST FORCED RESET * prototyping file, revision 2.0 "
       messg " This program resets the PIC 31k times/second  @ 4MHz Xtal "
       messg " Rigorously tested on an PIC16F877 datecode 9921BSL "
       messg " Morgan Olsson,, November 2000 "
;******************************* KONFIGURE ***********************************
       list      p=16f877
       errorlevel      -306 ;no Crossing page boundary warnings
       errorlevel      -302 ;no bank warnings
       radix           dec
;********************************** DEFINITION FILEs *************************
;********************************** REGISTERS ********************************
T1      EQU     0x20    ;general Temporary register 1
;********************************** RESET ************************************
       ORG     0x000
       nop     ;Needed for ICD debugger
       clrf    PCLATH
       goto    Init
;********************************* INTERRUPT *********************************
       ORG     0x004
       goto $  ;if false interrupt stop here to indicate (never happens)
;********************************* INIT **************************************
       clrf    STATUS

;Set up watchdog realistically as we normally use it
       movlw   b'11011101'; TMR0 on fosc/4, prescaler  /32 to Watchdog
       movwf   OPTION_REG

;PortE is used for monitoring
       clrf    PORTE
       bsf     STATUS,RP0      ;Bank 1
       movlw   b'00000010'     ;Make Port E a digital port,
       movwf   ADCON1          ;not analog inputs!

;-Indicator of personal taste. (PortE is made output later, see below)
       bcf     STATUS,RP0      ;Bank 0
       bsf     PORTE,2

;********************************* FAST RESET *********************************
;Design Morgan Olsson,


       clrf INTCON     ;disable interrupts
                       ;(Just to avoid spending time in an int)

       clrwdt  ;without this line the reset fails peridically -with the
               ;wdog freqency- probably depending on Wdog OSC output phase.
               ;-some undocumented connection.

       movlw   3  ;max number of tries (use higher value in final code!)
       movwf   T1 ;loop counter      (works first time if RA4 is steady)


;-Setup registers
       bcf     STATUS,RP0      ;Bank 0
       movlw   (1<<NOT_RBPU)|(1<<INTEDG)|(1<<T0CS)|(1<<T0SE)|(0<<PSA)|(0<<PS0)
; ( = set prescaler in from RA4 XOR T0SE, T0SE=High and prescale select = "/2")
       btfsc   PORTA,4         ;Read state of the XOR gate's input from PA4,
         xorlw (1<<T0SE)       ;set the other XOR input so XOR output is "1"
       bsf     STATUS,RP0      ;Bank 1
       movwf   OPTION_REG      ;Effectuate the setup
       bcf     STATUS,RP0      ;Bank 0
       clrf    TMR0            ;clear prescaler (also TMR0, but irrelevant)

;-Now clock the prescaler by toggling T0SE, thus prescaler input go from 1 to 0
       bsf     STATUS,RP0      ;Bank 1
       movlw   (1<<T0SE)
       xorwf   OPTION_REG,F

;-For testing, make Port E outputs in order to measure time from here,
       clrf    TRISE   ;until reset tristates portE again!
                       ;Measured: 6 Xtal OSC cycles.  Note; clrf effectuates
       ;during Q4, next instr during Q4 in next cycle, and from there
       ;to reset it is obviously only 2Q or one half instr time :)

;-Now the prescaler output apparently is "1", because...
       bsf     OPTION_REG,PSA  ;...assigning it to wdt cause immediate reset!

;--- if it did not work (maybe PORTA,4 have changed during this process): ---

       bcf     STATUS,RP0      ;Bank 0

;-Indicator of personal taste:
       bsf     PORTE,1         ;FastReset failed at least once

;-Retry a few times!
;It might fail due to RA4 is changing, therefor we try again, but not forever!
       decfsz  T1
         goto  FastResetLoop

;-Indicator of personal taste:
       bsf     PORTE,0         ;FastReset failed, waiting for Watchdog

       goto $  ;As last resort leave the Wdog in peace to time out as normal
               ;with shortest prescaler (already selected above).

;Because we are fiddling with the prescaler in the routine, and there are
;already some undocumented effects, and may be more, I do not feel sure that
;the watchdog will time out during theese conditions, therefor we just wait.

;Hard testing has proven it works as described!

;Testing have been performed feeding RA4 with 50% duty cycle square wave,
;sweeping from DC and up, and using max three tries (setting T1 = 3)
;The routine then begin "failing" (getting to goto $ and using normal Wdog)
;at first at about 22kHz, and then working again at 30-31kHz, then... etc.
;(all at 4MHz Xtal)
;Increasing the number of retries will narrow the non-working frequency bands,
;and increase the frequency of first "failure", thus increasing functionality.



part 3 200 bytes content-type:text/plain; charset="iso-8859-1"
(decoded quoted-printable)

Morgan Olsson         
Morgans Reglerteknik, Hällekås, 277 35 KIVIK, SWEDEN
   tel +46(0)414-446620, fax +46(0)414-672324

part 4 105 bytes
-- hint: To leave the PICList

2000\11\17@183928 by jamesnewton

face picon face
It is (updated) and has been at

and does no one see the little message on the bottom of every
page that says:

" members can LOGIN to post questions, add public or private
comments, links or even new pages(!). To start, fill out the form."

Once you log in, you can actually add notes, pages, routines, links,
comments, questions, etc... directly to the pages you are looking at.
Instantly. Without me. Do use HTML <PRE> and </PRE> tags around code
listings, etc... and don't stress if its not perfect... I get an email with
every post and I can go back and edit stuff to fix it if something goes

Ask Nik, he uses it pretty regularly to post updated version of his
routines, point out bugs, or broken links, etc...

Anyway, the site is for storeing answers derived from the
PICList, and I hope eventually I can reduce the amount of time I spend doing
that by allowing list members to directly post.

Thanks for the update Morgan.

James Newton (PICList Admin #3) 1-619-652-0593
PIC/PICList FAQ: or .org

{Original Message removed}

More... (looser matching)
- Last day of these posts
- In 2000 , 2001 only
- Today
- New search...