Program crash - how to trace the cause


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838

    Default Program crash - how to trace the cause

    Hello all ,

    I am working on program that on occasions is crashing and resetting the chip , can someone advise the methods to try and find out what may be causing the reset .

    The code is getting big , and compiles to about 60k so far and although the problem is showing up now , i am unsure if it was being hidden elsewhere prior.

    Regards

    Sheldon

  2. #2
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: Program crash - how to trace the cause

    what is the depth that you can have for while , wend loops

    It seems the problem may be that from my routines for key stroke checking

    I use a while <> KEY , wend loop to test for an " exit to the loop

    but as options go down into sub menu's , each need to be exited and the above menu's are looking for thier exit

    is this the best method for multilevel menu structure ?

    is it likly this structure is causing my issues ?

    cheers

    Sheldon

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: Program crash - how to trace the cause

    Hi,
    Examining the RCON register may give some clue to why the device resets, if it's the watchdog for example. The manual doesn't say anything about a limitation on the number of nested WHILE-WEND loops.
    You need to figure out where in the code "you are" when it crashes and/or if it has anything to do with the "depth" of the menu structure or if it's completely "random". Double and tripplecheck that you always end up at a RETURN when you've GOSUBed to some place.

    If you have a serial connection then adding a boatload of HSEROUT statements is another way to keep track of what's happening. Entering menu, level 2, level 3, setting 2, level 2 etc. If you're using MPLAB and have a PICKit3 or other device programmer/debugger then you might give source level debugging a shot. Unfortunately it's not supported in the MicroCodeStudio IDE.

    /Henrik.

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,631


    Did you find this post helpful? Yes | No

    Default Re: Program crash - how to trace the cause

    the manual says you can nest subs 27 levels deep on a pic18 , but that number includes any use of the stack by interrupts also.
    and that "The only PBP commands that are cause for concern when nesting are GOSUB and CALL. All other PBP commands may be nested with no stack concerns and no practical limit "

    edit
    that's pbp3
    Last edited by richard; - 3rd April 2014 at 12:28. Reason: clarify

  5. #5
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: Program crash - how to trace the cause

    each key event has a sub containing the menu and its key events sub , found just by changing menu pages i am trigering the crash, it takes 25 key presses of showing each page back n forth to trigger the reset

    even though the menu is not got 27 levels deep it does gosub to the next page to display and then run the keys sub for that next page

    ill try another way for testing , but its structure change of the entire menu system as it stands

  6. #6
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: Program crash - how to trace the cause

    well that seems to be why , thanks richard , the subs were growing in depth as each page was shown , this eventually crashed the chip.

    the answer is simple but a pain, use goto"s and routines label instead of gosub , for menus that have multi pages per sub section , where only one page is needed and not going deep then gosub can be used
    because i have number of structures that have while , wend loops nested gosub helped ensure the location of the return , with out me having to do it directly

    but a better monitor system for errors like this caused , i need to look into , able to monitor the stack usage depth is one tool that be nice

    cheers

    sheldon

Similar Threads

  1. Is there any way to debug/watch/trace macros?
    By mister_e in forum General
    Replies: 1
    Last Post: - 11th July 2011, 23:54
  2. how can i debug & trace my program
    By omid_juve in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 17th December 2007, 17:10
  3. HIDmaker from Trace Systems
    By Christopher4187 in forum USB
    Replies: 1
    Last Post: - 23rd March 2006, 22:14
  4. PBP / XP Crash
    By pondindustrial in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 27th November 2005, 03:16
  5. maximum oscillator trace length
    By woodygjw in forum Off Topic
    Replies: 8
    Last Post: - 20th May 2005, 03:16

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