RegForge

All parts / INA226

INA226 register map

Bidirectional current and power monitor with alert and I2C — Texas Instruments

10 registers I2C I²C 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F 8-bit reg addresses 75% bit coverage not yet human-verified
I²C address conflict. On its default address(es) this part collides with ADS1115 (0x48, 0x49, 0x4A, 0x4B); INA219 (0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F); PCA9685 (0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F). You cannot put them on the same bus without changing a strap pin, using an I²C multiplexer, or moving one to a second bus. See the full address map.

Get it as a C header

pip install regforge
regforge gen INA226 --out ./src --driver --tests

Writes ina226_regs.h with every address, mask and shift below, a bus-agnostic driver skeleton, and a file of compile-time assertions that make your compiler check the bit arithmetic. No API key needed — this part ships inside the package.

Not yet human-verified. Transcribed and mechanically validated — no overlapping fields, no out-of-range bits, reset values consistent with their fields — but not yet checked line-by-line against the datasheet. Verifying it is a useful half hour.

Registers

AddrRegisterAccessWidthResetDescription
0x00CONFIGRW160x4127Averaging, conversion times and operating mode
0x01SHUNT_VOLTAGERO16—Measured shunt voltage, two's complement, 2.5 uV per LSB
0x02BUS_VOLTAGERO16—Measured bus voltage, 1.25 mV per LSB
0x03POWERRO160x0000Calculated power. Reads zero until CALIBRATION has been written.
0x04CURRENTRO160x0000Calculated current, two's complement. Reads zero until CALIBRATION has been written.
0x05CALIBRATIONRW160x0000Current and power scaling. Set from the shunt resistance and the maximum expected current.
0x06MASK_ENABLERW160x0000Alert source selection and status flags
0x07ALERT_LIMITRW160x0000Threshold compared against whichever alert source MASK_ENABLE selects
0xFEMANUFACTURER_IDRO160x5449Manufacturer ID. Reads 0x5449, which is 'TI' in ASCII.
0xFFDIE_IDRO160x2260Die ID and revision. Reads 0x2260.

Bit layouts

Drawn MSB-first, the way the datasheet draws them. [7:5] means shift 5, width 3, mask 0xE0 — this is the notation that costs people a day when they read it backwards.

CONFIG  @  0x00  —  5 fields
RST[15]
—14
—13
—12
AVG[11:9]
VBUSCT[8:6]
VSHCT[5:3]
MODE[2:0]
BitsFieldAccessMaskResetDescription
[15]RSTW1P0x80000x00Write 1 to reset every register to its default; self-clearing
[11:9]AVGRW0x0E000x00Averaging mode
[8:6]VBUSCTRW0x01C00x04Bus voltage conversion time
[5:3]VSHCTRW0x00380x04Shunt voltage conversion time
[2:0]MODERW0x00070x07Operating mode

CONFIG.AVG values

ValueNameMeaning
0x00SAMPLES_11 sample (default)
0x01SAMPLES_44 samples averaged
0x02SAMPLES_1616 samples averaged
0x03SAMPLES_6464 samples averaged
0x04SAMPLES_128128 samples averaged
0x05SAMPLES_256256 samples averaged
0x06SAMPLES_512512 samples averaged
0x07SAMPLES_10241024 samples averaged

CONFIG.VBUSCT values

ValueNameMeaning
0x00US_140140 us
0x01US_204204 us
0x02US_332332 us
0x03US_588588 us
0x04US_11001.1 ms (default)
0x05US_21162.116 ms
0x06US_41564.156 ms
0x07US_82448.244 ms

CONFIG.VSHCT values

ValueNameMeaning
0x00US_140140 us
0x01US_204204 us
0x02US_332332 us
0x03US_588588 us
0x04US_11001.1 ms (default)
0x05US_21162.116 ms
0x06US_41564.156 ms
0x07US_82448.244 ms

CONFIG.MODE values

ValueNameMeaning
0x00POWER_DOWNPower down
0x01SHUNT_TRIGGEREDShunt voltage, triggered
0x02BUS_TRIGGEREDBus voltage, triggered
0x03SHUNT_BUS_TRIGGEREDShunt and bus, triggered
0x04POWER_DOWN_ALTPower down (alternate encoding)
0x05SHUNT_CONTINUOUSShunt voltage, continuous
0x06BUS_CONTINUOUSBus voltage, continuous
0x07SHUNT_BUS_CONTINUOUSShunt and bus, continuous (default)
MASK_ENABLE  @  0x06  —  11 fields
SOL[15]
SUL[14]
BOL[13]
BUL[12]
POL[11]
CNVR[10]
—9
—8
—7
—6
—5
AFF[4]
CVRF[3]
OVF[2]
APOL[1]
LEN[0]
BitsFieldAccessMaskResetDescription
[15]SOLRW0x80000x00Alert on shunt voltage over limit
[14]SULRW0x40000x00Alert on shunt voltage under limit
[13]BOLRW0x20000x00Alert on bus voltage over limit
[12]BULRW0x10000x00Alert on bus voltage under limit
[11]POLRW0x08000x00Alert on power over limit
[10]CNVRRW0x04000x00Alert on conversion ready
[4]AFFRO0x00100x00Alert function flag
[3]CVRFRO0x00080x00Conversion ready flag
[2]OVFRO0x00040x00Math overflow flag
[1]APOLRW0x00020x00Alert polarity. 0 = active low (default).
[0]LENRW0x00010x00Alert latch enable

Generated C header

What regforge gen INA226 writes for MASK_ENABLE:

/* ------------------------------------------------------------------------ */
/* MASK_ENABLE @ 0x06u  rw  16-bit  reset 0x0000u */
/* Alert source selection and status flags */
/* ------------------------------------------------------------------------ */

#define INA226_MASK_ENABLE                             0x06u
#define INA226_MASK_ENABLE_WIDTH                       16u
#define INA226_MASK_ENABLE_RESET                       0x0000u

/*   SOL bits [15] rw reset 0x00u -- Alert on shunt voltage over limit */
#define INA226_MASK_ENABLE_SOL_SHIFT                   15u
#define INA226_MASK_ENABLE_SOL_WIDTH                   1u
#define INA226_MASK_ENABLE_SOL_MASK                    0x8000u
#define INA226_MASK_ENABLE_SOL_GET(reg)                (((uint16_t)(reg) & 0x8000u) >> 15u)
#define INA226_MASK_ENABLE_SOL_SET(reg, val)           (((uint16_t)(reg) & (uint16_t)~0x8000u) | (((uint16_t)(val) << 15u) & 0x8000u))

/*   SUL bits [14] rw reset 0x00u -- Alert on shunt voltage under limit */
#define INA226_MASK_ENABLE_SUL_SHIFT                   14u
#define INA226_MASK_ENABLE_SUL_WIDTH                   1u
#define INA226_MASK_ENABLE_SUL_MASK                    0x4000u
#define INA226_MASK_ENABLE_SUL_GET(reg)                (((uint16_t)(reg) & 0x4000u) >> 14u)
#define INA226_MASK_ENABLE_SUL_SET(reg, val)           (((uint16_t)(reg) & (uint16_t)~0x4000u) | (((uint16_t)(val) << 14u) & 0x4000u))

/*   BOL bits [13] rw reset 0x00u -- Alert on bus voltage over limit */
#define INA226_MASK_ENABLE_BOL_SHIFT                   13u
#define INA226_MASK_ENABLE_BOL_WIDTH                   1u
#define INA226_MASK_ENABLE_BOL_MASK                    0x2000u
#define INA226_MASK_ENABLE_BOL_GET(reg)                (((uint16_t)(reg) & 0x2000u) >> 13u)
#define INA226_MASK_ENABLE_BOL_SET(reg, val)           (((uint16_t)(reg) & (uint16_t)~0x2000u) | (((uint16_t)(val) << 13u) & 0x2000u))

/*   BUL bits [12] rw reset 0x00u -- Alert on bus voltage under limit */
#define INA226_MASK_ENABLE_BUL_SHIFT                   12u
#define INA226_MASK_ENABLE_BUL_WIDTH                   1u
#define INA226_MASK_ENABLE_BUL_MASK                    0x1000u
#define INA226_MASK_ENABLE_BUL_GET(reg)                (((uint16_t)(reg) & 0x1000u) >> 12u)
#define INA226_MASK_ENABLE_BUL_SET(reg, val)           (((uint16_t)(reg) & (uint16_t)~0x1000u) | (((uint16_t)(val) << 12u) & 0x1000u))

/*   POL bits [11] rw reset 0x00u -- Alert on power over limit */
#define INA226_MASK_ENABLE_POL_SHIFT                   11u
#define INA226_MASK_ENABLE_POL_WIDTH                   1u
#define INA226_MASK_ENABLE_POL_MASK                    0x0800u
#define INA226_MASK_ENABLE_POL_GET(reg)                (((uint16_t)(reg) & 0x0800u) >> 11u)
#define INA226_MASK_ENABLE_POL_SET(reg, val)           (((uint16_t)(reg) & (uint16_t)~0x0800u) | (((uint16_t)(val) << 11u) & 0x0800u))

Compared with

Related parts

ADS1115
Texas Instruments
4 registers
INA219
Texas Instruments
6 registers
ADXL345
Analog Devices
30 registers

Source

Transcribed from TI INA226 datasheet (SBOS547) (hand-transcribed) (hand-transcribed). Hand-authored seed entry, not machine-extracted. Check against TI INA226 datasheet (SBOS547) before trusting it, then mark it verified.

Raw JSON · Report an error