Software reset


Closed Thread
Results 1 to 17 of 17

Thread: Software reset

  1. #1
    Join Date
    Feb 2005
    Location
    Portugal
    Posts
    79

    Default Software reset

    There are any way to do a software reset, not an hardware reset?

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    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.

  3. #3
    Join Date
    Feb 2005
    Location
    Portugal
    Posts
    79


    Did you find this post helpful? Yes | No

    Default MCLR pin

    What your saying is to connect, for example, porta.1 to MCLR pin and "write" porta.0 = 0 to make a software reset?!

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    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.

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Talking

    Mouhaha it's working
    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
    it never jump to 'there' or 'there2' and for sure 'there3'
    cool stuff!
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    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

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    @ 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.

  8. #8
    Join Date
    Feb 2005
    Location
    Portugal
    Posts
    79


    Did you find this post helpful? Yes | No

    Default Bad code

    The code doesnīt make a software reset to all registers
    @clrf PCLATH
    @ goto 0

    What i did wrong?

    Regards
    Leonel Monteiro

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    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.

  10. #10
    Join Date
    Feb 2005
    Location
    Portugal
    Posts
    79


    Did you find this post helpful? Yes | No

    Default 16f

    I'm using 16F so the @reset itīs not possible.
    I didnīt try the I/O method because my PCB is done...

  11. #11
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    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.

  12. #12
    Join Date
    Feb 2005
    Location
    Portugal
    Posts
    79


    Did you find this post helpful? Yes | No

    Default Put all registers to zero

    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

  13. #13
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    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.

  14. #14
    Join Date
    Feb 2005
    Location
    Portugal
    Posts
    79


    Did you find this post helpful? Yes | No

    Default

    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!

  15. #15
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    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.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  16. #16
    Join Date
    Feb 2005
    Location
    Portugal
    Posts
    79


    Did you find this post helpful? Yes | No

    Thumbs up It works...

    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

  17. #17
    Worayoot's Avatar
    Worayoot Guest


    Did you find this post helpful? Yes | No

    Default

    Thank you

    @ clrf PCLATH
    @ goto 0

    I use with 12F work very well

Similar Threads

  1. IC12F508 with Internal Oscillator and Software Reset
    By karan123 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 2nd October 2009, 16:13
  2. Software Stack
    By yasser hassani in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th December 2007, 10:04
  3. Replies: 3
    Last Post: - 26th November 2006, 21:47
  4. How to reset the pic by software ?
    By Shamir in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th October 2006, 16:43
  5. Software Driven Reset Routine
    By Tissy in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th April 2005, 00:53

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts