Code to ACTION reset events -


+ Reply to Thread
Results 1 to 2 of 2

Thread: Code to ACTION reset events -2832 days old

  1. #1
    Kapitan
    Guest Kapitan's Avatar

    0 Not allowed!

    Default Code to ACTION reset events -

    Hi all,
    A further development of the data logger for reset events -
    this is for use in main code to control and action unexpected and critical resets -
    Hope it helps someone.
    It is no good setting the fuses etc unless you are going to take some form of action (imho)

    Code:
    ;*******************************************************************************************************
    ;Unexpected Reset control - Joe Hanley (Captainslarty) 03 2012 - )
    
    ;NOTE this code PRESUMES and EXPECTS that you have the config fuses for the following set !
    ;WDT ON FULL - BOR ON - STACK OF UF ON.
    
    ;The PCON register Conditioning is based on data from the 16F1939 datasheet - it is probably the same for your device
    ;but you NEED to check the datasheet for PCON signalling in the event of reset. !!
    
    ;This subroutine will examine the state of the PCON (POWER CONTROL) SFR register on a restart event.
    ;In the event of unexpected reset events, then we will call appropriate subroutines to instruct our code to take action.
    ;The critical events could be classified as WDT Timout, or, a Stack overflow or underflow which would tend to indicate
    ;a MAJOR error in programming.
    ;Brown out, BOR - could be excluded, but again, may be indicative of a PSU issue - use as you require.
    ;The RESET Instruction Reset - is where your code has forced a restart by initiating a RESET command - 
    ;in that case - why did it happen ? - again can be excluded as you require.
    ;Some examples of what you 'may' decide to do are in the PCON Select Subs - and are purely a guide.
    
    ;Call as subroutine once your code has started.
    
    Reset_Diagnostics:
       
    ;Was the reset unwanted or critical ? 
        Select PCON
            Case 15    ; WDT  Reset
                GoSub WDT_Reset_Event
            Case 14    ; BOR  Reset
                GoSub BOR_Reset_Event
            Case 11    ; RESET Instruction Reset
                GoSub CODE_Reset_Event
            Case 143   ; Stack Overflow    Reset
                GoSub STACK_Overflow_Reset_Event
            Case 79    ; Stack Underflow   Reset
                GoSub STACK_Underflow_Reset_Event:
        End Select
    
        PCON = 001111    ; Reset PCON settings to known reset OFF states 
    
    Return
    ;*******************************************************************************************************
    
    WDT_Reset_Event:
    ;Here we have an unexpected Watchdog timer RESET of the main unit - 
    ;WHY did it happen - is it a coding issue etc ?
    ;you could, for example, set an led or an error code in this event to indicate to the user to call tech support.
    ;IF your code is in development, then it would be indicative of a programming error.
    Return
    ;-----------------------------
    
    BOR_Reset_Event:
    ;Continued BOR events are indicative or PSU issues - 
    ;This is a case where you may WANT to indicate to the user an issue - 
    ;Also if in development, you could have a PSU hardware issue.
    Return
    ;-----------------------------
    
    CODE_Reset_Event:
    ;WHY did we issue a RESET command in code ? - there must have been a reason so do something. !
    Return
    ;-----------------------------
    
    STACK_Overflow_Reset_Event:
    ;Here we have an unexpected STACK OVERFLOW RESET of the main unit - 
    ;THIS IS ALMOST CERTAINLY A MAJOR PROGRAMMING ISSUE ! AND NEEDS CORRECTING !!!
    ;SO WARN and do something about it !
    Return
    ;-----------------------------
    
    STACK_Underflow_Reset_Event:
    ;Here we have an unexpected STACK UNDERFLOW RESET of the main unit - 
    ;THIS IS ALMOST CERTAINLY A MAJOR PROGRAMMING ISSUE ! AND NEEDS CORRECTING !!!
    ;SO WARN and do something about it !
    Return
    ;-----------------------------
    ;*******************************************************************************************************

Attention

This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

The advertisements we display are relevant to this web site and your browsing history

Please consider supporting us by disabling your ad blocker.


Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

If you can, please report issues in the forum area WebSite / Forum Issues


Thank you for your attention.

  • #2
    Kapitan
    Guest Kapitan's Avatar

    0 Not allowed!

    Default Re: Code to ACTION reset events -

    slight typo


    in


    Case 79 ; Stack Underflow Reset
    GoSub STACK_Underflow_Reset_Event:

    the colon at the end needs removing....

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

    Thread Information

    Users Browsing this Thread

    There are currently 1 users browsing this thread. (0 members and 1 guests)

       

    Similar Threads

    1. multi action led running light using pic16f628A
      By kishorbodake in forum Absolute Beginners Section
      Replies: 3
      Last Post: 5th September 2016, 20:39
    2. [SOLVED !] multi action led running light using pic16f628A
      By kishorbodake in forum Projects discussion
      Replies: 4
      Last Post: 1st September 2016, 21:33
    3. T6963C o In-code reset
      By goodman in forum Proton Plus Compiler v3
      Replies: 0
      Last Post: 18th May 2012, 14:35
    4. Code to diagnose reset events - hopefully may assist someone.
      By Kapitan in forum Proton Plus Compiler v3
      Replies: 1
      Last Post: 6th March 2012, 11:56
    5. Can I set the brown out reset voltage from within the code
      By jonnykyoto in forum Proton Plus Compiler v3
      Replies: 5
      Last Post: 8th November 2006, 13:01

    Members who have read this thread since 11th November 2019, 11:09 : 0

    Actions :  (Set Date)  (Clear Date)

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

    Tags for this Thread

    Posting Permissions

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