AVR I2C Slave Tutorials

Developing a I2C Slave is Easy with a few subroutine modules.

  1. Improved I2C driver with FIFO support.
  2. Using a simple message protocol.
  3. Support modules to build and parse messages into process calls.
  4. A simple service loop to tie it all together.
  5. Master and Slave architectures explained.

Now, why would you need an I2C Slave? The simplest reason is that you never have enough I/O lines when using single chip microcontrollers. You may want to read ten sensors and your controller only has eight analog inputs or your robot design is almost done, but you don't have enough digial lines to add the LCD display that you'd like.

At a systems level, it's easier to expand, reconfigure, and adjust a system if your controls and sensors are modular, independent, networked, and intelligent. This allows you to make changes without having to do major rework of hardware or software.

And besides, you've always wondered what those two extra pins (SDA and SCL) on your Arduino board were good for.

This is a series of projects that takes the developer through increasingly complex design examples to help understand one way to build an I2C Slave module based on an Atmel AVR chip. Both TWI and assisted-USI interface drivers will be used to provide support for the respective ATmega and ATtiny AVR famimilies.
A simple scheduler will also be introduced to show one way to handle multiple tasks within a limited resource environment.

NOTE: You will need a way to program a blank AVR controller chip. This is normally done using an Atmel ISP pod; about $40 through many suppliers.

These are the breakdowns that will be used to build up a given Slave project. All examples use the Atmel Studio 6.2 IDE and an Arduino board to test.

These are the projects provided.

see also: Register based I2C Slave to look more like hardware.
Target: megaAT 0-series (ATmega4808/4809, AVR128DA48, etc.)

SideNote: Since the drivers do the heave lifting for using I2C, you really don't need to know a lot of the gritty details. However, for the curious, this is the source of information.
UM10204 I2C-bus specification and user manual.