Work with I2C form Your PC
Posted by admin on March 27 2008 12:01:45
A new product called the BV4221 is a USB to I2C converter. It requires no special software to enable I2c devices to be controlled. All that is needed is some terminal software such as HyperTerminal or BV Terminal. The device can also 'spy' on the I2C bus so that hard to define problems can be debugged. You can watch what is going on on the I2C bus.
Extended News

BV4221 USB to I2C Two Way Converter

This is a device that you can plug into the USB and use it to drive I2C devices, it will also work the other way round and inspect the I2C bus for debugging purposes. This device will enable a standard PC to control, LCD's, Analogue to Digital Converters, Real time Clocks, Temperature Sensors, EEPROM storage etc. In fact any I2C device on the market. This can be done interactively or through a user program. The full data sheet and example programs can be fount at www.pin1.org

The device has a USB connector at one end and the I2C interface at the other. There are built in pull up resistors to the SDA and SCL line and also LED indicators. The indicators are illuminated when the bus lines are high, thus when both are illuminated the bus is free. This is very useful for detecting 'locked up' devices.

The BV4221 presents itself to the PC as a COM port, this is useful because it can be used with any terminal software, it will work with Windows and Linux.

At switch on the BV4221 waits for the enter key to be pressed, it will then select an appropriate Baud rate based on that. In the above example BV Terminal is being used but this could be any terminal software. The prompt by default is 0x42>, this indicates working in hex mode with a slave device address of 0x42 (66 decimal).

As an example to write to a serial EEPROM the values 1,2 & 3 at address 0x120:

The first command Aa0, changes the address to 0xA0. In the second line the letters and numbers have the following meaning:

s    sends a start condition

1 20    sends to the EEPROM the address where the data is to be written, this is a 16 bit value, hence to bytes are sent.

1 2 3    are the data that is stored at the address

p is the stop condition

To read the data back:

s 1 and 20 set the address as before

r    sends a re-start condition, telling the EEPROM that we now wish to read it. A restart is a start condition followed by the address plus 1 and so 0xA1 will have been sent.

g-3    this gets three bytes from the EEPROM, it will send the appropriate NACK on the last byte to tell the EEPROM no more bytes are required. As can be seen the bytes that were restored are retrieved.

All of the above can of course be done under program control so that an automated system can be implemented, a temperature logger for example. Very little knowledge of electronics is needed as all of the functionality is within the I2C devices.

Inspector Mode

As well as acting as a master device the BV4221 can also 'spy' on the I2C bus and present what it sees to the terminal. This has some limitations in bandwidth but can be very useful for debugging and learning about I2C.

Features

Note that the Baud rate selects from 9,600,14,400,19,200,28,400 and 11,5200 only.

What you get

The BV4221 comes with a comprehensive data sheet. A copy of this can be downloaded from this site. To see the article on using this hardware with Just Basic go here. To purchase the BV4221 go to the shop.