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.

WDT and recognize if harwdare reset or a software reset

Other Parts Discussed in Thread: EK-TM4C123GXL

Hi,

I am using a TM4C123AH6PMI microcontroller.

I have the following problems. During Test with spikes (Electromagnetic compatibility) my cpu stops to work.

I would like to setup a WDT software, but I do not know exactly how to do. The needs for WDT is that

if my CPU stops, the WDT should resets (software reset) the CPU and on startup I should be able to recognize that

the reset was from WDT intead of a hardware reset. (Maybe there is a register that indicates this, which Register?)

Finally, I would like to allocate some variables in a bank that is not initialized if the startup is from WDT.

I hope I was able to explain my request.

 Best

  • Hello Fortunato,

    So for starters we have a Watchdog timer example in TivaWare under C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c123gxl\watchdog

    That will show you basic configurations.

    if my CPU stops, the WDT should resets (software reset) the CPU and on startup I should be able to recognize that

    the reset was from WDT intead of a hardware reset. (Maybe there is a register that indicates this, which Register?)

    The System Control Register 7, Reset Cause (RESC) (offset 0x05C) provides this ability. You can read that register on startup and determine what triggered the system reset.

    Finally, I would like to allocate some variables in a bank that is not initialized if the startup is from WDT.

    Normally I would recommend using the EEPROM for this but since you are using Revision 6 silicon you will need to review the EEPROM errata for the device and determine if those could prevent you from doing what is necessary.

    If the EEPROM is not viable, you could store the variables in Flash memory or if you think power loss won't occur then you could use SRAM as well.

    In any case, you would be checking the result of RESC and then you can access those variables accordingly.

    Best Regards,

    Ralph Jacobi

  • Hi,

    I would want to use SRAM, since my CPU stucks for some reason (some EC spikes).

    There is no power loss, I can eventually have some checksum on those variables so

    that in some way I can think they are not corrupted.

    Could you please show me an example of linker script where some variables are marked

    not to be initialized. Actually, I have my own initializing routine but I think that 

    they are automatically cleaned by startup.

    Best

  • Hello Fortunato,

    I'm not entirely following the ask here. Can you provide some more detail and maybe share some snippets of the variables you are trying to allocate?

    I am not certain that a linker script modification is the optimum solution here.

    Best Regards,

    Ralph Jacobi