下载

Maxim > Design Support > Technical Documents > Application Notes > Microcontrollers > APP 3588
Keywords: microcontroller, MAXQ2000, I2C driver, C Compiler, IAR, MAXQ, microcontrollers, ADCs,
analog digital converters, micros
APPLICATION NOTE 3588
Software I²C Driver for the MAXQ2000
Microcontroller
Nov 04, 2005
Abstract: I²C (inter-integrated circuit) is a 2-wire interface that allows bidirectional communication
between integrated circuits. This application note describes a software I²C driver for the MAXQ2000
microcontroller that permits I²C communication at 100kHz or 400kHz using any of the microcontroller's
GPIO pins. Microcontrollers from the MAXQ family are well suited for such bit-banging applications
because of their high-speed, flexible GPIO modules, and separate I/O supply voltage.
Introduction
An I²C (inter-integrated circuit) is a 2-wire interface that allows bidirectional communication between
integrated circuits. This appnote describes the maxqi2c library, a software I²C driver for the MAXQ2000
microcontroller (µC).
The maxqi2c library is written in C using extensions that compile using the IAR Embedded Workbench
for MAXQ. It consists of two files: maxqi2c.h and maxqi2c.c. When these files are included in a
MAXQ2000 firmware project, they permit flexible I²C communication at 100kHz or 400kHz using any of
the µC's GPIO pins.
Microcontrollers from the MAXQ family are well-suited for such bit-banging applications because of their
high-speed, flexible GPIO modules and separate I/O supply voltage.
The files for the example project discussed in this appnote are available for download from Maxim
Integrated Products.
Configuring the maxqi2c Library
The user should copy the maxqi2c library files (maxqi2c.h and maxqi2c.c) to the MAXQ2000 project
directory and configure the files to create the desired I²C interface. All configurations are done by editing
the following code (Listing 1), which can be found at the top of the maxqi2c.h source file:
Listing 1. maxi2c.h customization code.
/* USER MUST CUSTOMIZE THE FOLLOWING DEFINE STMTS - START */
// Enter the port used for SDA and SCL
#define SDA_PORT 0
#define SCL_PORT 0
Page 1 of 8