There are any way to do a software reset, not an hardware reset?
There are any way to do a software reset, not an hardware reset?
By software only ... no.... and yes.
If you connect one extra i/o to your MCLR pin... yes
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
What your saying is to connect, for example, porta.1 to MCLR pin and "write" porta.0 = 0 to make a software reset?!
yep. just make sure your PORTA.1 is set to high or as input when you boot the pic and that's it.
EDIT: i don't know if it's working but i just read my 18F2320 datasheet about the STKPTR register. Probably you can set the stack register full and do few gosub to get a Stack Full Resets too. never tested it. i'll try this now and let you know.
Last edited by mister_e; - 21st February 2005 at 19:32.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Mouhaha it's working
it never jump to 'there' or 'there2' and for sure 'there3'Code:' program to perfom an software reset ' PIC18F2220 DEFINE LOADER_USED 1 DEFINE OSC 20 DEFINE HSER_RCSTA 90h DEFINE HSER_TXSTA 24h DEFINE HSER_BAUD 9600 loop var byte begin: STKPTR = 0 ' clear Stack resets bits hserout ["software RESET",13,10] start: for loop = 10 to 0 step -1 hserout ["reset in ",dec loop,13,10] pause 1000 next STKPTR = $FF ' full stack pointer gosub there pause 1000 goto start there: hserout ["I'm supposed to be die now ;o("] pause 1000 gosub there2 return there2: hserout ["I'm supposed to be die now for the 2nd time ;o("] pause 1000 gosub there3 return there3: hserout ["I'm supposed to be die now for the 3rd time ;o("] pause 1000 return
cool stuff!
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
if you're using an 18F type pic, you can just use the reset command.
@ reset
if using a 16F,
asm
clrf PCLATH
goto 0
endasm
Darrel
DT
@ reset
yup... always read the whole datasheet.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
The code doesnīt make a software reset to all registers
@clrf PCLATH
@ goto 0
What i did wrong?
Regards
Leonel Monteiro
well i'm not sure to agree 100% about that method. Are you still using the 18F series?
looks no 'cause you must use @ reset
did you try with the i/o reset method?
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
I'm using 16F so the @reset itīs not possible.
I didnīt try the I/O method because my PCB is done...
my assumption is by using this method, it jumps only to the reset vector. So it doesn't produce any effects on the registers... so the i/o style should be considered.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Yes, I agree with you...
What do you think the ideia to do software reset putting all my registers to zero. Itīs easier and i havenīt to use the I/O method
not sure of it... humm... what is the purpose of this software reset?
What do you expect?
Do you set all your registers at the begining?
Sure you can set all register to the default POR before the goto reset vector ... but those registers are not all to zero... see datasheet for POR setting of each registers.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
The ideia in doing the software reset itīs that:
I have a "security command" and when this contact is closed the circuit workīs normally, but when the contact opens I donīt want that the circuit workīs, but when the contact closes again all my registers goes like it seems we remove the power, like it was the first time we were running the program...
What Iīm thinking to do is modify the value on the registers that I've modified and put them at zero or to the value that had at the beginning!
If you just need to clear all RAM (variables) then use the CLEAR command.
If you want to start over from location 0 simulating a power-up condition, and clear RAM without a hardware reset, then use;
@ clrf PCLATH
@ goto 0
And place CLEAR as the first BASIC instruction.
If you have a security check routine that needs to clear RAM when a switch changes state, use the CLEAR command on entry to the routine.
Lots of options.
Thankīs, your solution works.
I was forgetting the clear command...
The code to do a software reset is:
clear
@ clrf PCLATH
@ goto 0
Best regards
Leonel
Bookmarks