Jump to content

Recommended Posts

I need to reset a 16F877A from software. There are a few ways I can think to do it. I wanted to just use "goto 0" or something like "goto reset_vector", but the first doesn't like the absolute address and I don't know of a label for it (this will leave garbage on the call stack, but since the stack wraps around and overflows are ignored, it shouldn't be an issue). Right now I have it as:

asm {
  movlw 0
  movwf _pclath
  movwf _pcl
}

but it seems a bit obscure compared to a "goto".

 

I've also seen people force a watchdog timer reset with an infinite loop, but that will mess up if the WDT is disabled and other things could go wrong with that.

 

So, is some reset() function/macro or reset_vector label I haven't seen, or should I leave it like it is?

Link to post
Share on other sites

edt,

 

If you are going to use a "soft reset" to goto the reset vector make sure that you initialize ALL of the function blocks for ADC, Comparators, serial I/O, MSSP, timers and any others I may have missed, to a condition that's appropriate for your application.

 

Be sure to disable the interrupts and force the bank and page selects to page zero before you goto the reset vector.

 

Something like:

 _asm 
{
  clrwdt
  clrf    _intcon
  clrf    _status
  clrf    _pclath
  clrf    _pcl
}

 

cac.

Link to post
Share on other sites
You could use a pin to control !MCLR and just be aware of its state.

OR you could simple use:  _asm{RESET} if your device supports

the reset command(most PICs do).

The hardware is already designed, so _MCLR wouldn't work. I don't think the 'F73 supports a RESET instruction (I can't find it in the documentation). Good suggestions, though.
If you are going to use a "soft reset" to goto the reset vector make sure that you initialize ALL of the function blocks...

Very good point... I had forgotten about all of that mess. Forcing a WDT reset may be the best option in this case, even if it isn't perfect.
Link to post
Share on other sites
  • 2 weeks later...
edt,

 

If you are going to use a "soft reset" to goto the reset vector make sure that you initialize ALL of the function blocks for ADC, Comparators, serial I/O, MSSP, timers and any others I may have missed, to a condition that's appropriate for your application.

 

Be sure to disable the interrupts and force the bank and page selects to page zero before you goto the reset vector.

 

Something like:

 _asm 
{
  clrwdt
  clrf    _intcon
  clrf    _status
  clrf    _pclath
  clrf    _pcl
}

 

cac.

 

I need software reset too..hey this one really works! Thanks!

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...