Playing with Arduino
A page to record my playing with Arduino
SREG

Abstract

The SREG is a status register of ATmega328P.

Source Code

The SREG is defined in hardware/tools/avr/avr/include/avr/common.h as below.

1
2
3
4
5
6
7
8
9
#define SREG _SFR_IO8(0x3F)
#  define SREG_C  (0)
#  define SREG_Z  (1)
#  define SREG_N  (2)
#  define SREG_V  (3)
#  define SREG_S  (4)
#  define SREG_H  (5)
#  define SREG_T  (6)
#  define SREG_I  (7)

0x3F is an I/O address of SREG. It calls _SFR_IO8().

The status register is a 8bit register. The meanings of each bit are shown below.

Bit76543210
ITHSVNZC

I: Global Interrupt Enable

T: Bit Copy Storage

H: Half Carry Flag

S: Sign Bit

V: Two’s Complement Overflow Flag

N: Negative Flag

Z: Zero Flag

C: Carry Flag

Version

Arduino 1.8.13/avr-gcc 7.3.0-atmel3.6.1-arduino

Last Update

June 19, 2020

inserted by FC2 system