NetBurner 3.5.6
PDF Version
I2C Address Scan

I2C Address Scanner for SAME70 Microcontrollers

A utility application for NetBurner SAME70-based platforms that scans I2C buses to discover connected devices and report their addresses.

Overview

This application provides a systematic way to scan I2C buses for connected devices, making it an essential tool for hardware verification, system integration, and troubleshooting. It scans the complete I2C address range (0-127) and reports all discovered device addresses in both serial console and web interface formats.

Supported Platforms

  • MODM7AE70 - Supports up to 3 I2C modules (I2C0, I2C1, I2C2)
  • SBE70LC - Supports up to 2 I2C modules (I2C0, I2C1)

Features

  • Complete I2C address range scanning (0-127)
  • Hexadecimal address reporting
  • Device count display
  • Configurable bus speed (default: 100kHz)
  • Platform-specific pin configuration
  • Web interface for remote monitoring
  • Interactive menu system via serial console
  • I2C bus reset capability
  • Remote console support through web browser

Hardware Pin Assignments

SBE70LC Platform

I2C0 (Module 0)

  • Data (TWD0): J1[16]
  • Clock (TWCK0): J1[17]

I2C1 (Module 1)

  • Data (TWD1): J3[4]
  • Clock (TWCK1): J3[6]

MODM7AE70 Platform

I2C0 (Module 0)

  • Data (TWD0): P2[39]
  • Clock (TWCK0): P2[42]

I2C1 (Module 1)

  • Data (TWD1): P2[22]
  • Clock (TWCK1): P2[12]

I2C2 (Module 2)

  • Data (TWD2): P2[26]
  • Clock (TWCK2): P2[23]

Important Configuration Requirements

MODM7AE70 I2C1 Special Setup

For I2C1 on the MODM7AE70 platform, pin P2.12 requires special configuration due to multiplexing between processor ports PA5 and PB5:

  1. Navigate to \nburn\platform\MODM7AE70\include\pinconstants.h
  2. Uncomment #define P2_12_USE_B5 to enable PB5
  3. Comment out the PA5 definition

Without this configuration, the application will display an error message and I2C1 will not function.

How It Works

The scanning process uses the following methodology:

  1. Initializes the specified I2C module with platform-specific pin configurations
  2. Iterates through all possible I2C addresses (0-127)
  3. Attempts to read from register 0x0 of each address
  4. Waits for an ACK response from potential devices
  5. Records and reports addresses that respond with ACK
  6. Stores results for web interface display
  7. Provides total device count

Usage Instructions

Getting Started

  1. Connect I2C devices to the appropriate platform pins
  2. Compile and flash the application to your SAME70 board
  3. Open a serial terminal (115200 baud recommended)
  4. The application automatically scans I2C module 0 on startup

Interactive Menu

After initialization, the application presents a menu:

1. Scan
2. Reset I2C Bus
I2C Peripheral Class.
Definition i2c.h:213
@ Bus
Non-multiplexed bus mode (write only). Separate address and data buses. Reads are performed as AD-Mux...
  • Option 1: Performs a new I2C bus scan
  • Option 2: Resets the I2C bus (useful for clearing bus errors)

Web Interface Access

The application includes a built-in web server:

  1. Connect to the device's IP address via web browser
  2. View scan results on the main page
  3. Access the remote console at console.html for interactive control

Sample Output

Serial Console

Initializing I2C Module: 0
Scanning I2C Module: 0
Scanning I2C bus for devices...
Found a device at address 0x48
Found a device at address 0x68
Done. Found a total of 2 device(s) on the bus.
1. Scan
2. Reset I2C Bus

Web Interface

Number of addresses responded: 2
0x48
0x68

Configuration Options

I2C Module Selection

#define I2C_MODULE (0) // Default uses I2C0

Bus Speed Configuration

#define I2C_BUS_SPEED (100000) // 100kHz default

Applications

This utility is particularly useful for:

  • Hardware Verification: Confirming proper device connections
  • Address Discovery: Finding actual I2C addresses of connected devices
  • System Integration: Verifying I2C bus integrity during development
  • Troubleshooting: Diagnosing communication issues
  • Remote Diagnostics: Web-based device management
  • Documentation: Generating device address maps for system documentation

Technical Specifications

  • Address Range: 0x00 to 0x7F (128 addresses)
  • Detection Method: Register read with ACK detection
  • Bus Speed: Configurable, default 100kHz
  • Communication: Single byte register read from address 0x0
  • Web Server: Built-in HTTP server with remote console
  • Storage: Results stored in global arrays for web access

Dependencies

  • NetBurner RTOS
  • I2C library (i2c.h)
  • Platform-specific definitions (pins.h)
  • System initialization (init.h)
  • Network libraries for web interface
  • Remote console support (remoteconsole.h)

Building and Deployment

  1. Set up NetBurner development environment
  2. Select target platform (MODM7AE70 or SBE70LC)
  3. Configure pin multiplexing if using MODM7AE70 I2C1
  4. Compile the project
  5. Flash to target board
  6. Connect serial terminal for monitoring
  7. Optionally access web interface for remote operation

Troubleshooting

Common Issues

No devices detected:**

  • Verify physical connections and power supply
  • Check device compatibility with scanning method
  • Some devices may not respond to general address scans

    I2C1 issues on MODM7AE70:**

  • Check pin multiplexing configuration in pinconstants.h
  • Ensure P2_12_USE_B5 is properly defined

    Web interface not accessible:**

  • Verify network configuration
  • Check HTTP server initialization
  • Confirm IP address assignment

Error Messages

  • Error: Invalid module number - Module number exceeds platform limits
  • invalid moduleNum - Module number validation failed
  • *** Error: must change function of P2.12 to PB5 - Pin multiplexing configuration required

Important Notes

  • Not all I2C devices respond to address scanning
  • Some devices may require specific initialization sequences
  • Device datasheets may include or exclude read/write bits in address specification
  • Bus speed compatibility varies between devices
  • Pull-up resistors are required on SDA and SCL lines, typically 4.7k ohms.

File Structure

  • main.cpp - Main application with scanning logic
  • index.html - Web interface homepage
  • style.css - Web interface styling
  • ReadMe.txt - Detailed technical documentation