index    previous    next

original image


The I2C object provides a two wire communications bus which can be used for communicating with I2C devices (e.g I2C EEPROMs) and also other CPUs.

The I2C bus can be driven from

  • a timer interrupt
  • inline delay loops (polled)
  • VCLK timer
Using a VCLK driven I2C bus allows comms to be performed as a low priority background task. It also removes timing problems associated with systems distributed over serveral CPUs of greatly differing speeds. Driving the comms in the background allows the CPU to drive other critical I/O with geater ease and accuracy (e.g. driving stepper motors or timming external events).

Using a timer interrupt driven I2C bus allows comms to be performed as a high priority foreground task.

Simulation Details

The I2C object generates machine code which is directly executable in the target system. No additional debug code is generated for the target when the simulator is used in place of a real CPU. Signaling between different CPUs is performed by reading from and writing to real CPU I/O ports. The simulator uses XPUT objects mapped directly to the CPU's I/O ports to route the signals between simulated CPUs (see INPUT objects for further information).

Code Generation

The I2C object has several properies associated with it which are used to guide the code generator during the code generation phase. These properties are accessed via the I2C settings object dialog.

The properties are:

  • I2C Module ID
  • SCL Port ID
  • SDA Port ID
  • I2C Address
  • Driver Capabilities (Master / Slave)
  • Bit Pump Type (interrupt, polled, VCLK)
The SCL and SDA ports are XPUT objects which map directly to I/O bits in I/O ports on a real CPU (see INPUT objects for detailed information on XPUT objects). These ports are normally connected to corresponding SCL and SDA ports on I2C objects belonging to other CPU objects connected to the same I2C bus.

Adding I2C Objects To A Design

Normally a I2C object is added to a design by copying it from the template window to the drawing window or from an existing I2C object already on the drawing window. It must form part of a CPU if code is to be generated for it. This is done by placing it within the perimitor of a CPU object and using the I2C objects add to group function or gather function to tie it to the CPU.

Related Information

CPU objects
INPUT objects
WIRE objects
VCLK objects