Reset types and the RCON register


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2010
    Posts
    2

    Default Reset types and the RCON register

    I have a program that resets ocassionally and to help find out why, I thought I'd make use of the RCON register. There is a hardware watchdog that toggles MCLR, and the internal watchdog is disabled.

    The datasheet (18F8722) is a bit confusing with every reset type setting the flags in a different way, but I suppose that's to be expected for these kinds of flags. I was just wondering if anyone has used the RCON register successfully on an 18F with PBP.

    Also, MCLoader is being used for the bootloader, but I have been unable to find anything saying if it messed with RCON or not.

    Any help would be appreciated. I will post my progress as I go.

    John

  2. #2
    Join Date
    Apr 2010
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    Here's what I have so far

    Code:
    '-------------- Reset Type -----------------------------------------------------
    ' manage the RCON/STKPTR flags and come up with a sane reset indication
    ' there will probably be only one bit set, but anything is possible
    ' especially with regards to the powerdown bit, which gets set by a SLEEP instr.
    '
    '  0 brownout, 1 poweron, 2 powerdown, 3 wdt timeout
    '  4 reset instruction, 5 (unused), 6 stack underflow, 7 stack full
    
        ResetTypeMask   var byte
        ResetTypeMask = 0
        
    GetResetType:
        ' Brown-out Reset
        if RCON & %11 = %10 then ' BOR 0, POR 1 
            ResetTypeMask.0 = 1
            RCON.0 = 1 ' set BOR
        endif
    
        if RCON.1 = 0 then ' POR 0
            ResetTypeMask.1 = 1
            RCON.1 = 1 ' set POR
        endif
        
        ' RESET instruction
        if RCON.4 = 0 then ' RI 0
            ResetTypeMask.4 = 1
            RCON.4 = 1  ' set RI
        endif
        
        ' WDT reset
        if RCON.3 = 0 then ' TO 0
            ResetTypeMask.3 = 1
            ' TO is read-only
        endif
        
        ' Stack Full
        if STKPTR.7 = 1 then ' STKFUL 1
            ResetTypeMask.7 = 1
            STKPTR.7 = 0
        endif
        
        ' Stack Underflow
        if STKPTR.6 = 1 then ' STKUNF 1
            ResetTypeMask.6 = 1
            STKPTR.6 = 0
        endif
        
        ' Powerdown Detection
        if RCON.2 = 0 then ' PD 0
            ResetTypeMask.2 = 1
            ' PD is read-only
        endif

  3. #3
    Join Date
    Feb 2008
    Posts
    4


    Did you find this post helpful? Yes | No

    Default Re: Reset types and the RCON register

    Hi jbutera,

    Did you find a way to do this?

    I have a similar problem...

    I am performing a hardware MCLR (on rare occasions), and wish to detect when it occured.

    My line of code is:

    If RCON.1 = 0 Then GoTo mclr

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