PDA

View Full Version : How to force a 16F628A to reset using PBP statement.



Wirecut
- 9th March 2008, 17:57
Hi to all.

I have made more search but I do not have found a way to reset the PIC using PBP statement.

I need at run time, in some particular condition, to force the PIC to reset; a reset similar to momentary ground the MCLR pin.

Many thanks for you help.

Leo

Archangel
- 9th March 2008, 18:25
Hello Wirecut
Here is 1 way, tie an unused pin to the mclr pin and bring it low in software.

Wirecut
- 10th March 2008, 08:46
Hi Joe.

many thanks for your suggestion, but unfortunatelly I do not have spare pins to dedicate to this use.

Ciao

Leo

Acetronics2
- 10th March 2008, 09:01
Hi,

Other solution ... WDT Timeout ! ...


Alain

Bruce
- 10th March 2008, 11:25
You could use the WDT, but then you would need to insert an assembler routine that looped
until the WDT reset the PIC. Otherwise PBP will automatically clear the WDT.

You have the option of telling PBP not to clear WDT, but then it's up to you to manage it,
and that can really be a pain.

Another option is to just jump to location 0. PCLATH=0 followed by @ GOTO 0 works if you
just want to start over from 0.

sayzer
- 10th March 2008, 12:22
....

Another option is to just jump to location 0. PCLATH=0 followed by @ GOTO 0 works if you
just want to start over from 0.

Bruce,

Could you be a little more specific with your example please?

Thanks,

Bruce
- 10th March 2008, 12:32
Sure. If you want to re-start from location 0, then;



X VAR BYTE

TOGGLE 0

Main:
FOR X = 0 TO 50
IF X = 20 THEN
PCLATH = 0
@ GOTO 0 ' start over from 0 if X = 20
ENDIF
NEXT X
GOTO Main

END
This isn't exactly the same as a hardware reset, but it's close.

sayzer
- 19th March 2008, 09:32
Thanks Bruce.

Since you say that it is not a hard reset but close, will this clear any return addresses in the stack if there is any?


Thanks.

Bruce
- 19th March 2008, 13:40
No it does not clear the stack.