Hello,
I'm using a PIC16F819 in a small project and I need to reset the PIC via the software.
I will explain:
I use the EEprom of the PIC and I a special case I need to clear the EEprom and make the PIC start the whole program from start (so all variables may be cleared).
At this point I "kinda" clear the EEprom by writing 255 via a loop from address 0 to 255. This looks good.
But after this the PIC should start from scratch at the point where it starts after a reset (or after the a power up).
I found two software resets:
asm("reset");
and
GOTO 0x000
Is there a better way of doing this?
It's not a problem that all variables are cleared, and even no problem if the whole EEprom gets wiped.
All help is welcome!
Software reset PIC
Moderator: Benj
-
- Posts: 1314
- Joined: Sun Jan 15, 2012 3:15 pm
- Has thanked: 474 times
- Been thanked: 458 times
- Contact:
Re: Software reset PIC
Hi
you could use the watchdog timer , if enabled you have to regularly check it, so you would let it time out where you wanted a reset to occur (search the forum as there are some good posts on using it, another way would be to use a sparepin and use it to drive the mclr pin when a reset is required
Regards
Dazz
you could use the watchdog timer , if enabled you have to regularly check it, so you would let it time out where you wanted a reset to occur (search the forum as there are some good posts on using it, another way would be to use a sparepin and use it to drive the mclr pin when a reset is required
Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php
- JohnCrow
- Valued Contributor
- Posts: 1367
- Joined: Wed Sep 19, 2007 1:21 pm
- Location: Lincolnshire
- Has thanked: 364 times
- Been thanked: 716 times
- Contact:
Re: Software reset PIC
Hi
Ive used a C command to restart the device in the past.
Just put a C Box into the flowchart at the point you need to restart and enter the command reset( );
Though I expect its similar to asm("reset");
Ive used a C command to restart the device in the past.
Just put a C Box into the flowchart at the point you need to restart and enter the command reset( );
Though I expect its similar to asm("reset");
1 in 10 people understand binary, the other one doesn't !
-
- Posts: 502
- Joined: Wed Nov 07, 2007 6:51 pm
- Location: Antwerp Belgium
- Has thanked: 121 times
- Been thanked: 108 times
- Contact:
Re: Software reset PIC
Thank you both for your quick response
I've put the reset in a C block, this seems to do the trick, but on an other forum I read that there could be a problem if the reset is called from in a macro?
Something to do with a stack overflow?
I'm not that deep into PIC programming to understand if this way of resetting is harmful for the way the PIC works..
Could this way of resetting the PIC cause harm?
I've put the reset in a C block, this seems to do the trick, but on an other forum I read that there could be a problem if the reset is called from in a macro?
Something to do with a stack overflow?
I'm not that deep into PIC programming to understand if this way of resetting is harmful for the way the PIC works..
Could this way of resetting the PIC cause harm?
-
- Posts: 1314
- Joined: Sun Jan 15, 2012 3:15 pm
- Has thanked: 474 times
- Been thanked: 458 times
- Contact:
Re: Software reset PIC
Hi Mju
Have a look at the datasheet for your device as theres a fair bit in there about the different types of reset
Regards
Dazz
Have a look at the datasheet for your device as theres a fair bit in there about the different types of reset
Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
- Contact:
Re: Software reset PIC
Reset will never create stack overflows. After a reset the program execution will start with an empty stack and variables will be either set to their default values (if specified in your code) or uninitialized. What happens to peripherals and registers can be found in the data sheet of your specific micro controller.MJU wrote: I've put the reset in a C block, this seems to do the trick, but on an other forum I read that there could be a problem if the reset is called from in a macro?
Something to do with a stack overflow?
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis