# I2C Peripheral Addresses and Bus Configuration for DAC5578 and ADS7830 in PLFM RADAR Firmware

> Configure I2C addresses and bus settings for DAC5578 and ADS7830 in PLFM RADAR firmware. Understand peripheral addresses and bus configurations for efficient hardware integration.

- Repository: [NawfalMotii79/PLFM_RADAR](https://github.com/NawfalMotii79/PLFM_RADAR)
- Tags: how-to-guide
- Published: 2026-08-20

---

**DAC5578 DACs use I²C bus `hi2c1` with addresses `0x48` and `0x49`, while ADS7830 ADCs use `hi2c2` with addresses `0x48`, `0x49`, `0x4A`, or `0x4B` depending on hardware pin-strapping.**

The PLFM RADAR project uses a STM32F7 microcontroller to manage multiple analog peripherals through separate I²C buses. Understanding the **I2C peripheral addresses and bus configuration for DAC5578 and ADS7830** devices is essential for modifying the firmware or debugging communication issues. This article breaks down the exact addresses, HAL handles, and initialization code found in the open-source firmware.

## I2C Bus Assignment Strategy

The firmware deliberately separates DAC and ADC devices across two I²C peripherals to eliminate bus contention and match the PCB routing.

| Peripheral | I²C Bus (HAL Handle) | Purpose |
|------------|---------------------|---------|
| **DAC5578** (2× devices) | `hi2c1` | Gate voltage (Vg) control for power amplifier channels |
| **ADS7830** (3× devices) | `hi2c2` | Idq measurement and thermal monitoring |

This separation allows simultaneous transactions without arbitration delays and simplifies timing requirements for the 8-channel DAC updates.

## DAC5578 I2C Configuration

Each **DAC5578** is an 8-channel, 8-bit digital-to-analog converter. The PLFM RADAR Main Board contains two instances for independent PA channel control.

### Default I²C Addresses

| Device | Address | PCB Reference | Handle Name |
|--------|---------|---------------|-------------|
| First DAC5578 | `0x48` | U7 | `hdac1` |
| Second DAC5578 | `0x49` | U69 | `hdac2` |

### Initialization Code

In [`main.cpp`](https://github.com/NawfalMotii79/PLFM_RADAR/blob/main/main.cpp) (lines 1845-1855), both DACs are initialized with `&hi2c1` and their respective addresses:

```c
#include "DAC5578.H"

DAC5578_HandleTypeDef hdac1, hdac2;

/* Initialize first DAC5578 at 0x48 */
bool ok1 = DAC5578_Init(&hdac1, &hi2c1, 0x48, 8,
                        GPIOB, DAC5578_LDAC_PIN, 
                        GPIOB, DAC5578_CLR_PIN);

/* Initialize second DAC5578 at 0x49 */
bool ok2 = DAC5578_Init(&hdac2, &hi2c1, 0x49, 8,
                        GPIOB, DAC5578_LDAC_PIN, 
                        GPIOB, DAC5578_CLR_PIN);

```

The `DAC5578_Init()` function signature confirms:
- **Bus**: `hi2c1` pointer (first STM32 I²C peripheral)
- **Resolution**: Fixed at 8 bits (`resolution = 8`)
- **Control pins**: `LDAC` and `CLR` on GPIOB

### Post-Initialization Setup

After successful init, the code configures both devices for synchronized updates:

```c
/* Clear all outputs to zero scale */
DAC5578_SetClearCode(&hdac1, DAC5578_CLR_CODE_ZERO);
DAC5578_SetClearCode(&hdac2, DAC5578_CLR_CODE_ZERO);

/* Enable LDAC broadcast for all 8 channels */
DAC5578_SetupLDAC(&hdac1, 0xFF);
DAC5578_SetupLDAC(&hdac2, 0xFF);

```

## ADS7830 I2C Configuration

The **ADS7830** is an 8-channel, 8-bit analog-to-digital converter with address-selectable I²C operation. The PLFM RADAR firmware addresses three instances across two functional domains.

### Address Selection via Pin Strapping

The ADS7830 datasheet (and `ADS7830.H`) defines four possible addresses based on the `ADDR` pin connection:

| ADDR Pin Connection | I²C Address |
|---------------------|-------------|
| GND | `0x48` |
| VDD | `0x49` |
| SDA | `0x4A` |
| SCL | `0x4B` |

### Deployed Instances

| Function | Address | PCB Reference | Handle Name | Lines in [`main.cpp`](https://github.com/NawfalMotii79/PLFM_RADAR/blob/main/main.cpp) |
|----------|---------|---------------|-------------|---------------------|
| Idq measurement (ch 0-7) | `0x48` | U88 | `hadc1` | 1900-1909 |
| Idq measurement (ch 0-7) | `0x4A` | U89 | `hadc2` | 1910-1919 |
| Thermal monitoring | `0x49` | U10 | `hadc3` | 1990-1999 |

### ADC Initialization Code

All three instances use `&hi2c2` (the second STM32 I²C peripheral):

```c
#include "ADS7830.H"

ADS7830_HandleTypeDef hadc1, hadc2, hadc3;

/* Idq ADC #1: ADDR = GND → 0x48 */
bool okA = ADS7830_Init(&hadc1, &hi2c2, 0x48,
                        ADS7830_SDMODE_SINGLE, 
                        ADS7830_PDIRON_ADON);

/* Idq ADC #2: ADDR = SDA → 0x4A */
bool okB = ADS7830_Init(&hadc2, &hi2c2, 0x4A,
                        ADS7830_SDMODE_SINGLE, 
                        ADS7830_PDIRON_ADON);

/* Thermal monitor: ADDR = VDD → 0x49 */
bool okC = ADS7830_Init(&hadc3, &hi2c2, 0x49,
                        ADS7830_SDMODE_SINGLE, 
                        ADS7830_PDIRON_ADON);

```

The `ADS7830_SDMODE_SINGLE` parameter configures single-ended measurements; the driver also supports differential mode via `ADS7830_SDMODE_DIFF`.

### Reading ADC Channels

```c
/* Read channel 3 from Idq ADC #1 */
uint8_t raw_value = ADS7830_Measure_SingleEnded(&hadc1, 3);

/* Convert TMP37 thermal sensor reading to temperature */
float temperature_c = raw_value * 0.64705f;  // 165°C / 255 LSB

```

## Key Source Files

| File | Path | Purpose |
|------|------|---------|
| `DAC5578.H` | `9_Firmware/9_1_Microcontroller/9_1_1_C_Cpp_Libraries/DAC5578.H` | Handle struct, API prototypes, command constants |
| [`DAC5578.c`](https://github.com/NawfalMotii79/PLFM_RADAR/blob/main/DAC5578.c) | [`9_Firmware/9_1_Microcontroller/9_1_1_C_Cpp_Libraries/DAC5578.c`](https://github.com/NawfalMotii79/PLFM_RADAR/blob/main/9_Firmware/9_1_Microcontroller/9_1_1_C_Cpp_Libraries/DAC5578.c) | I²C write/read implementation, power modes |
| `ADS7830.H` | `9_Firmware/9_1_Microcontroller/9_1_1_C_Cpp_Libraries/ADS7830.H` | Address constants, measurement mode enums |
| [`ADS7830.c`](https://github.com/NawfalMotii79/PLFM_RADAR/blob/main/ADS7830.c) | [`9_Firmware/9_1_Microcontroller/9_1_1_C_Cpp_Libraries/ADS7830.c`](https://github.com/NawfalMotii79/PLFM_RADAR/blob/main/9_Firmware/9_1_Microcontroller/9_1_1_C_Cpp_Libraries/ADS7830.c) | I²C command sequencing, conversion timing |
| [`main.cpp`](https://github.com/NawfalMotii79/PLFM_RADAR/blob/main/main.cpp) | [`9_Firmware/9_1_Microcontroller/9_1_3_C_Cpp_Code/main.cpp`](https://github.com/NawfalMotii79/PLFM_RADAR/blob/main/9_Firmware/9_1_Microcontroller/9_1_3_C_Cpp_Code/main.cpp) | System startup, peripheral instantiation |

## Common Configuration Issues and Solutions

### Address Collision on Shared Bus

The DAC5578 at `0x48` and `0x49` and the ADS7830 at `0x48`/`0x49` would conflict if placed on the same bus. The **separate `hi2c1`/`hi2c2` assignment** prevents this.

### Verifying Bus Communication

Both drivers return boolean status from `*_Init()`. The firmware checks these and logs via `DIAG` macros:

```c
if (!ok1) {
    DIAG_ERROR("DAC5578 @ 0x48 initialization failed");
}

```

### Modifying Addresses for Custom Boards

To change an ADS7830 address:
1. Physically restrap the `ADDR` pin (GND, VDD, SDA, or SCL)
2. Update the address constant in [`main.cpp`](https://github.com/NawfalMotii79/PLFM_RADAR/blob/main/main.cpp) initialization call
3. No driver modification needed—the `ADS7830.H` already defines all four options

## Summary

- **DAC5578 devices** connect to **`hi2c1`** at addresses **`0x48`** and **`0x49`** for gate voltage control
- **ADS7830 devices** connect to **`hi2c2`** at addresses **`0x48`**, **`0x4A`**, and **`0x49`** (selected by pin strapping) for current and temperature sensing
- Initialization occurs in [`main.cpp`](https://github.com/NawfalMotii79/PLFM_RADAR/blob/main/main.cpp) lines 1845-1855 (DACs) and 1900-1999 (ADCs)
- The **separate bus architecture** eliminates address conflicts despite overlapping address ranges

## Frequently Asked Questions

### What I2C addresses can the ADS7830 support?

The ADS7830 supports four addresses based on the `ADDR` pin strapping: `0x48` (GND), `0x49` (VDD), `0x4A` (SDA), and `0x4B` (SCL). The PLFM RADAR firmware uses `0x48`, `0x4A` for Idq measurement and `0x49` for thermal monitoring. These are hardware-determined and cannot be changed via software.

### Why are DAC and ADC devices on separate I2C buses?

The `DAC5578` and `ADS7830` both use addresses in the `0x48-0x49` range. Placing them on separate buses (`hi2c1` and `hi2c2`) prevents address collisions. This design also isolates the DAC's real-time gate voltage updates from the ADC's sampling operations, improving timing determinism.

### How do I add a fourth ADS7830 to the system?

Strap the new device's `ADDR` pin to SCL to select address `0x4B` (unused in the current design). Add a new `ADS7830_HandleTypeDef` declaration, then call `ADS7830_Init()` with `&hi2c2` and `0x4B`. Ensure your PCB routing connects the device to the second I²C peripheral's SDA/SCL lines.