EmbeddedRelated.com
Forums

Get Last Reset Reason

Started by "Ohad Gal (Eltav)" July 31, 2007
Hello,

Suppose during operation, my MSP430F2272 gets a reset, how can I know the
following:

1. Program counter before the reset
2. Reason of the last reset (Watchdog, flash violation, memory
overflow, stack overflow, division by zero, etc.)

I noticed that a reset is actually an interrupt as any other

(#define RESET_VECTOR (15 * 2u) /* 0xFFFE Reset [Highest Priority]
*/)

but how can I get the previous PC and/or the reason?

Regards,

Ohad Gal

Beginning Microcontrollers with the MSP430

Unlike an interrupt, reset will not stack the PC. Thus there is no
direct way to find out the value of PC before the reset.

Stack overflow, division by zero, etc. will not cause a reset. Evens
that do cause a reset are described in the User's Guide. Various flags
are set and can be read or cleared by software afterwards to determine
the cause of the reset.

For MSP430F2272, the User's Guide is called SLAU114 and current
revision is SLAU114c.pdf.

--- In m..., "Ohad Gal (Eltav)" wrote:
>
> Hello,
>
>
>
> Suppose during operation, my MSP430F2272 gets a reset, how can I
know the
> following:
>
> 1. Program counter before the reset
> 2. Reason of the last reset (Watchdog, flash violation, memory
> overflow, stack overflow, division by zero, etc.)
>
>
>
> I noticed that a reset is actually an interrupt as any other
>
> (#define RESET_VECTOR (15 * 2u) /* 0xFFFE Reset [Highest
Priority]
> */)
>
> but how can I get the previous PC and/or the reason?
>
>
>
> Regards,
>
>
>
> Ohad Gal
>
>
>
>
>