beautypg.com

Mcu status register - mcusr, Internal voltage reference, Voltage reference enable signals and start-up time – Rainbow Electronics ATmega163L User Manual

Page 26: Interrupt handling, Atmega163(l)

background image

ATmega163(L)

26

MCU Status Register - MCUSR

The MCU Status Register provides information on which reset source caused an MCU reset.

Bits 7..4 - Res: Reserved Bits

These bits are reserved bits in the ATmega163 and always read as zero.

Bit 3 - WDRF: Watchdog Reset Flag

This bit is set if a watchdog reset occurs. The bit is reset by a power-on reset, or by writing a logic zero to the flag.

Bit 2 - BORF: Brown-out Reset Flag

This bit is set if a brown-out reset occurs. The bit is reset by a power-on reset, or by writing a logic zero to the flag.

Bit 1 - EXTRF: External Reset Flag

• This bit is set if an external reset occurs. The bit is reset by a power-on reset, or by writing a logic zero to the flag.

Bit 0 - PORF: Power-on Reset Flag

This bit is set if a power-on reset occurs. The bit is reset only by writing a logic zero to the flag.

To make use of the reset flags to identify a reset condition, the user should read and then reset the MCUSR as early as
possible in the program. If the register is cleared before another reset occurs, the source of the reset can be found by
examining the reset flags.

Internal Voltage Reference

ATmega163 features an internal bandgap reference with a nominal voltage of 1.22 V. This reference is used for Brown-Out
Detection, and it can be used as an input to the Analog Comparator and ADC. The 2.56 V reference to the ADC is also gen-
erated from the internal bandgap reference.

Voltage Reference Enable Signals and Start-up Time

The voltage reference has a start-up time that may influence the way it should be used. The maximum start-up time is TBD.
To save power, the reference is not always turned on. The reference is on during the following situations:

1.

When the BOD is enabled (by programming the BODEN fuse)

2.

When the bandgap reference is connected to the Analog Comparator (by setting the ACBG bit in ACSR).

3.

When the ADC is enabled.

Thus, when the BOD is not enabled, after setting the ACBG bit, the user must always allow the reference to start up before
the output from the Analog Comparator is used. The bandgap reference uses typically 10 µA, and to reduce power con-
sumption in Power Down mode, the user can avoid the three conditions above to ensure that the reference is turned off
before entering Power Down mode.

Interrupt Handling

The ATmega163 has two 8-bit Interrupt Mask control registers: GIMSK - General Interrupt Mask register and TIMSK -
Timer/Counter Interrupt Mask register.

When an interrupt occurs, the Global Interrupt Enable I-bit is cleared (zero) and all interrupts are disabled. The user soft-
ware must set (one) the I-bit to enable nested interrupts. The I-bit is set (one) when a Return from Interrupt instruction -
RETI - is executed.

When the Program Counter is vectored to the actual interrupt vector in order to execute the interrupt handling routine, hard-
ware clears the corresponding flag that generated the interrupt. Some of the interrupt flags can also be cleared by writing a
logic one to the flag bit position(s) to be cleared.

If an interrupt condition occurs when the corresponding interrupt enable bit is cleared (zero), the interrupt flag will be set
and remembered until the interrupt is enabled, or the flag is cleared by software.

If one or more interrupt conditions occur when the global interrupt enable bit is cleared (zero), the corresponding interrupt
flag(s) will be set and remembered until the global interrupt enable bit is set (one), and will be executed by order of priority.

Bit

7

6

5

4

3

2

1

0

$34 ($54)

-

-

-

-

WDRF

BORF

EXTRF

PORF

MCUSR

Read/Write

R

R

R

R

R/W

R/W

R/W

R/W

Initial value

0

0

0

0

See bit description