This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Reset Reason Status Register?

For a C2000 F2803x, Is there a register that details the reason for a reset, such as a BOR, POR, watchdog, external?

Tom

  • Hi Tom,

    The only status flag I know of is the "WDFLAG" in the SysCtrlRegs.WDCR Register. Check out System Control and interrrupts Guide Section 3.4.5

    Best regards

    Andreas

  • Hi!

    I have the same question. So far I found the WDFLAG, as Andreas said, and the MCLKSTS in PLLSTS  register (NMI Watchdog reset). Are there other flags you found?

    Thanks,

    Monica

  • HI, here is a post regarding the WD Flag, there seems to be an issue with it:

    http://e2e.ti.com/support/microcontrollers/tms320c2000_32-bit_real-time_mcus/f/171/t/131284.aspx

    One thing I ended up doing was creating a RAM location(with checksum).  During power up if the RAM is invalid, I assume a power up event.  During run time, I put cookies into the checksum RAM at various points in the code.  If a reset occurs, I can determine the cause of reset in general terms.

    Tom

  • Hi!

    Thanks! I took a short look at that discussion. I wonder if the same happens with MCLKSTS. But until then, I must understand how you solved the issue. I'm not an expert.... yet :)

    Regards,

    Monica

  •  

    You define and reserve a RAM segment in the linker such as (make sure that you adjust the RAM segment to remove what you are adding)

    MEMORY

    {

    ...

    PAGE 1 :

    ...

    HEALTHRAM :

    origin = 0x0007F0, length = 0x000010 /* preserved RAM between resets  assume power to chip was not lost */

    }

    SECTIONS {

    ....

    statusram : > HEALTHRAM PAGE = 1

    ....

     

    In your code define a set of variables:

    #pragma

    DATA_SECTION(statushigh, "statusram");

    #pragma

    DATA_SECTION(statuslow, "statusram");

    u16 statushigh;

    u16 statuslow;

    Add two functions:

    u16 GetCookie(u16 *cookie)

    {

    u16 rval=0;

    if ( statushigh == ~statuslow)

    {

    rval = 1;

    }

    *cookie = statushigh;

    return rval;

    }

    void

    SetCookie(u16 cookie)

    {

    statushigh = cookie;

    statuslow = ~statushigh;

    }

    During power up you can check the status of the variable by calling GetCookie().  You can put snap shots of registers, or other things by calling SetCookie()

    Hope this helps.

     

  • Thanks again!

    So I could SetCookies() in the interrupts  (I use interrupt mode for both Watchdog and NMIWatchdog) and after reset I read the RAM to get the reason of reset.

    Regards,

    Monica

  • Yes.  Just be careful, since you need to ensure atomic access to the variables if you access in background (non interupt) code, you may need to add a disabble interrupt.  Or, rewrite in assembly to avoid read/modify/write.

    If you only set in interrupt, and during a power up interrupts are off, you will be ok.

     

    Tom

  • Thank you Tom!

    Was really helpful!

    I still have one question: what's the purpose of *cookie in GetCookie? I've always had troubles with pointers...

    In my code I have defined:

    Uint16 WD_reset;
    Uint16 *WD_rst;

    I don't know if it's correct, was the only way I could compile.

    Then in INT:

    WD_reset = any_value;
    SetCookie(WD_reset);

    And I check:

    flag = GetCookie(WD_rst);

    I see statushigh, statuslow get the correct value, the flag also. But WD_rst is a memory location which I cannot read. In the debugger appears: Memory map prevented reading on target memory.

    I'm not sure I read the code correctly, but I thought at the memory address WD_rst I  would find 'any_value'.

    I've tried to write:

    WD_rst = &WD_reset; // GetCookie would overwrite WD_reset with statushigh, right?

    But I get a compilation error.

    Regards,

    Monica

  • Monica, you want to pass an address to the function as follows, (note example of how I'm using this)

    u16 rval;

    u16 cookie=0;

    rval = GetCookie(&cookie);

        if ( rval == 0)
    {
    SetCookie( COOKIE_POWERON);

    }

    Tom

  • Thanks a million Tom!

    This was of GREAT help! Now I can have a different code for each reset cause ( so far, WD reset, NMI reset and power-on). For NMI reset I've posted a question http://e2e.ti.com/support/microcontrollers/tms320c2000_32-bit_real-time_mcus/f/171/t/172402.aspx#629940 , but I didn't get an answer yet. Have you worked with it too?

    Regards,

    Monica

  • sorry I haven't worked with this. if your use an external crystal you can instrument a board so you can pull the crystal out during runtime. I've done this before.
  • In the moment I use the ControlCard as provided by Texas, without any crystal. But anyway, the procedure you showed me works great with NMI reset too.

    Regards,

    Monica