Back

SMBus

Loading views...

SMBus Protocol

Overview

SMBus (System Management Bus) is a subset of I2C designed by Intel for power management and system health monitoring in computers and embedded systems. It adds defined timeouts, packet error checking (PEC), and specific command protocols on top of the I2C physical layer.


1. Theory & Fundamentals

  • Derived from I2C but with stricter timing, voltage, and protocol rules
  • Operates at 10kHz–100kHz (SMBus 1.0), up to 400kHz (SMBus 3.x)
  • Adds PEC (Packet Error Code) — CRC-8 for error detection
  • Defined timeouts prevent bus lockup (25ms max)
  • Alert Response Address (ARA): Device signals interrupt, host identifies it
  • Smart Battery: Primary use case — laptop battery management

2. Frame / Packet Structure

Transaction types:
- Send Byte:      S | ADDR W | A | command | A | P
- Write Byte:     S | ADDR W | A | command | A | data | A | P
- Read Byte:      S | ADDR W | A | command | A | Sr | ADDR R | A | data | NA | P
- Block Write:    S | ADDR W | A | command | A | count | A | data[0..N] | [PEC] | P

3. Protocol Mechanics

  • Alert# line: Open-drain interrupt; ARA (0x0C) resolves which device alerted
  • PEC: Optional CRC-8 appended to transaction; receiver validates
  • Timeouts: Clock stretching limited to 25ms; transaction timeout 35ms
  • Device default addresses defined by standard (e.g., smart battery at 0x0B)

4. Hardware Implementation

  • Same as I2C: SDA, SCL, pull-ups (4.7kΩ)
  • Optional SMBALERT# line: Additional open-drain interrupt wire
  • Common SMBus ICs: BQ2084 (battery gauge), LM75 (temp sensor), TPS40425 (power controller)

5. Register-Level / Configuration

// SMBus uses same I2C peripheral but with timeout and PEC enabled
// STM32: Enable PEC in I2C CR1
I2C1->CR1 |= I2C_CR1_ENPEC; // Enable PEC

// Read byte with PEC
uint8_t SMBus_ReadByte(uint8_t addr, uint8_t cmd) {
    I2C_Start(); I2C_Send(addr << 1 | WRITE); I2C_Send(cmd);
    I2C_RepeatedStart(); I2C_Send(addr << 1 | READ);
    uint8_t data = I2C_Read(ACK);
    uint8_t pec  = I2C_Read(NACK); // PEC byte
    I2C_Stop();
    return data; // Verify PEC separately
}

6. Driver / Software Development

// Smart Battery status read
uint16_t Battery_GetVoltage(void) {
    return SMBus_ReadWord(0x0B, 0x09); // SBS command 0x09 = Voltage
}
uint8_t Battery_GetSOC(void) {
    return SMBus_ReadByte(0x0B, 0x0D); // 0x0D = RelativeStateOfCharge
}

7. Debugging & Testing

  • Logic analyzer with SMBus/I2C decode; verify PEC bytes
  • Use open-source smbus-tools on Linux for quick testing
  • Common issues: Timeout violations (device too slow); PEC mismatch; missing SMBALERT handler

8. Real-World Applications

  1. Laptop battery management (Smart Battery Specification)
  2. Server power supply monitoring (PMBus)
  3. DIMM SPD (Serial Presence Detect) reading
  4. Motherboard temperature/voltage monitoring
  5. UPS battery management

9. Advanced Topics & Edge Cases

  • SMBus vs PMBus: PMBus adds manufacturing-specific power commands on SMBus
  • Host Notify Protocol: Alternative to SMBALERT#
  • Group command: Write to multiple devices atomically
  • Address resolution protocol (ARP): Dynamic address assignment

10. Standards & Variants

Version Speed Features
SMBus 1.0 100kHz Basic, PEC
SMBus 2.0 100kHz ARP, host notify
SMBus 3.0 400kHz Higher speed
PMBus 1.x 400kHz Power management superset

💡 Practical Examples

Example 1: Read battery state of charge

uint8_t soc = SMBus_ReadByte(0x0B, 0x0D); // 0–100%

Example 2: Read DIMM SPD data

// SPD EEPROM at I2C address 0x50–0x57
uint8_t density = SMBus_ReadByte(0x50, 0x04); // Module density

Example 3: Enable SMBALERT interrupt

// Configure GPIO interrupt on SMBALERT# pin
// On interrupt: read ARA to find which device alerted
uint8_t alerter = SMBus_ReadByte(0x0C, 0); // ARA

🧪 Practice Questions

Beginner

  1. What is the main difference between SMBus and I2C?
  2. What is PEC and what algorithm does it use?
  3. What is the SMBus clock frequency range?
  4. What is the Alert Response Address (ARA)?
  5. What is SMBus primarily used for?

Intermediate

  1. How does SMBus PEC protect against transmission errors?
  2. Implement an SMBus Read Word transaction in C.
  3. What happens if an SMBus device holds the clock beyond 25ms?
  4. How do you identify which device triggered SMBALERT#?
  5. What is the Smart Battery Specification and how does it use SMBus?

Advanced

  1. Implement a complete Smart Battery monitor reading all SBS data.
  2. Add PEC verification to all SMBus transactions.
  3. Implement SMBus ARP for dynamic device address assignment.
  4. Design a multi-battery management system over SMBus.
  5. Trace and debug an SMBus timeout issue in a battery system.

Hands-on Projects

  1. Battery Monitor: Read SoC, voltage, current, temperature from laptop battery.
  2. Server Health Monitor: Read fan speeds, voltages via SMBus from server motherboard.
  3. Smart Charger: Control charging via SMBus commands to battery management IC.

Checklist

  • [ ] Explain SMBus vs I2C differences
  • [ ] Implement PEC calculation and verification
  • [ ] Read Smart Battery data over SMBus
  • [ ] Handle SMBALERT# interrupt and ARA resolution
  • [ ] Use SMBus timeout handling
  • [ ] Interface with PMBus power controller
  • [ ] Read DIMM SPD data
  • [ ] Implement SMBus ARP
  • [ ] Debug with logic analyzer
  • [ ] Write complete SMBus transaction library