Restart 18F2620


Results 1 to 9 of 9

Thread: Restart 18F2620

Threaded View

  1. #3
    Join Date
    Sep 2005
    Location
    Dayton, Ohio
    Posts
    72


    Did you find this post helpful? Yes | No

    Default

    I had a similar problem when moving from 16F to 18F. Finally I discovered it was a STACK OVERFLOW reset. The 16F does not care if you overflow the stack, but the 18F does!

    If you call a subroutine (GOSUB) and you do not RETURN from that subroutine, because of a GOTO or IF-THEN or TimeOut within the subroutine (looks like you have them), then the last address PUSHed onto the stack does not get POPped from the stack and it eventually overflows causing a reset.

    If you exit the subroutine without a RETURN, then you must manually POP the stack. (I also use the STKPTR = 0 in some parts of the program, though I know this is cheating a bit).

    So... anytime you are exiting a subroutine early (not using Return) you should POP the stack:

    @ POP

    On the 16F you can keep pushing onto the stack with no problems, so you never see the problem until you move to an 18F chip.

    I'm sure someone else here can provide a more detailed (accurate?) explanation of the 18F stack pointer, but I hope this at least helps you in the right direction.

    Jim
    Last edited by milestag; - 26th June 2007 at 14:57. Reason: add info
    Jim Robertson
    "MilesTag" DIY Lasertag
    www.lasertagparts.com/mtdesign.htm
    Dayton, Ohio

Similar Threads

  1. In Circut Debug (ICD) buttons palet is disable for 18F2620
    By muskut in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th June 2010, 06:21
  2. 18F2620 tmr0 and interrupts
    By astouffer in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 8th March 2009, 01:56
  3. X-10 and the proper XOUT statement for 18F2620
    By JohnP in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 10th December 2007, 23:04
  4. 18F2620 compile problems in PBP
    By Joe Rocci in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 13th August 2006, 11:11
  5. How can I find Code Loader 18F2620 files ?
    By muskut in forum General
    Replies: 1
    Last Post: - 14th October 2005, 13:26

Members who have read this thread : 0

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