Stat

Functions

void stat_rdrstcause()

Find what has caused the latest reset by reading the System Reset Interrupt Vector register.

This function sets bits in the global variable rstcause, which is initialised to zero. Only the highest priority interrupt is read.

int stat_rstcause_is_lpm5wu()

Check if the reset was caused by a routine wakeup from LPMx.5.

LPMx.5 is entered each time the state machine runs during normal operation. This is to minimise power consumption. The Program Counter resets to zero and RAM is powered down. The Real Time Clock (RTC) peripheral triggers a reset (and an exit from LPMx.5) after one minute has elapsed.

The stat_rdrstcause() function must be called first.

Returns

Non-zero when the reset has been caused by a wake-up from LPMx.5

void stat_setclockfailure()

Set the clock failure bit in the rstcause global variable.

unsigned int stat_get(bool *err, bool *borsvs, int resetsalltime)

Get status information from the rstcause global variable.

Parameters
  • err[out] Pointer to an error flag. The flag is set if the latest reset has been caused by an error.

  • borsvs[out] Pointer to the Brownout or SVS reset flag. The flag is set if the latest reset has been caused by a voltage drop to the SVSH or BOR levels.

  • resetsalltime[in] Number of resets that have occurred from the factory.

Returns

A 16-bit status word for inclusion in the URL by cuplCodec. The upper byte is resetsalltime/16. The lower byte is a copy of the rstcause variable.

Variables

unsigned int rstcause = 0

Reset cause global variable.