The I2C master protocol

Netzer supports I2C master emulation since version 1.2.

The most data transactions are done transparently by Netzer. But a few protocol specifiers are implemented for handling the special states of I2C.

The termination character

The character 0x00 in the TCP/IP communication has special meaning in terminating any pending I2C transmission. If Netzer sends a 0x00 either the bus is busy or a slave does not respond on address or data bytes. In the latter cases the bus is freed with a stop condition automatically. If Netzer receives 0x00 while a I2C transmission is pending, the transmission will be finished with a automatic generated stop condition.

If 0x00 should be sent via the I2C interface it must be escaped with a leading backspace. Therefore also the backslash itself must be escaped.

The start condition and the slave address byte

A start condition is automatically announced on the bus, if Netzer gets the first character via the TCP/IP serial socket. If an error occurs while announcing the start condition Netzer responds with a '0x00'. I2C protocol defines the very first byte after the start condition as slave address. Netzer sends a '0x00' via TCP/IP if no slave responds (ACK bit was '1'). Also a stop condition is initiated by Netzer. After the successful transmission of the slave address Netzer sends '0xFF' via TCP/IP.

General call address

The I2C general call address 0x00 addresses all slaves on the I2C bus. Sending 0x00 as the very first byte is allowed as an exception of the Netzer protocol. The escaping backslash MUST not be used.

The R/W bit

Netzer also checks the R/W bit (LSB) of the slave address character.
If the R/W bit is cleared a transmission from master to slave is initiated. Each byte received by Netzer via the TCP/IP socket is directly sent to the slave (consider escaping!). In response Netzer sends via TCP/IP either '0xFF' as positive acknowledge (ACK bit was '0') or '0x00' as negative acknowledge (ACK bit was '1'). In case of a negative acknowledge Netzer initiates a stop condition on the bus.
If the R/W bit is set a transmission from slave to master is initiated (clock is generated by I2C master). After the successful transmission of the slave address Netzer waits for further bytes on the TCP/IP socket. On receiving a byte via TCP/IP a byte is pulled from the slave and is sent via TCP/IP. In case the received byte is '0x00' the transmission is over and Netzer generates a stop condition on the bus. Any other value pulls the next byte from slave.

Repeated start

I2C supports repeated start. This symbol concatenates a stop and start condition while a I2C transmission is pending without freeing the bus inbetween. The special character 's' (0x73) in TCP/IP stream initiates the repeated start on the bus. Therefore the 's' must be escaped during normal stream transmission to Netzer. Exception to escaping 's' is the very first character (slave address) analog to the "General Call address" section. Receiving an 's' from Netzer has no special meaning but 's' :)

Examples

Take a look at the following picture for circuiting a I2C EEPROM IC as slave to Netzer.
EEPROM_Example.gif

Connecting a simple EEPROM to Netzer

Accessing the Netzer serial socket from Windows

HyperTerminal is a bit exhausting for transfering hexadecimal characters. Here is an alternate method doing this. Checkout the tools com2tcp and com0com (http://com0com.sourceforge.net/). After installing com0com as Null modem emulator you get new virtual COM ports named CNCA0 or CNCB0. Now you can start com2tcp like this:
com2tcp --ignore-dsr \\.\CNCA0 ne041a4c.local 64000
The command connects to Netzer named "ne041a4c.local" with the serial socket running on port 64000. If successfully connected the socket is bound to COM port CNCA0. Due the Null modem mechanism all the data is mirrored between the virtual COM ports generated by com0com. With your prefered terminal program, you are able to connect to i.e CNCB0. Characters written to CNCB0 are sent to CNCA0 and to Netzer. Received characters from Netzer are received on CNCA0 and later on CNCB0.

EEPROM slave address

The EEPROM has the slave address 0x50. Because the LSB is reserved for the R/W indicator the address is shifted left by one: 0xA0.

Writing to the EEPROM

See the following byte sequence for writing a 0x55 to memory address 0 of the EEPROM:
Write per TCP/IP to Netzer: 0xA0 0x5C 0x00 0x55 0x00
Answer from EEPROM received per TCP/IP from Netzer: 0xFF 0xFF 0xFF

  1. 0xA0 is the slave address with the R/W bit cleared, means write access.
  2. Netzer answers with 0xFF, indicating the available slave.
  3. 0x5C 0x00 transfers the memory address 0 - of course must be backslashed ('\' = 0x5C)
  4. Netzer answers with 0xFF, successful transfered memory address.
  5. 0x55 is the value which is written to EEPROM
  6. Netzer answers with 0xFF, successful transfered value.
  7. 0x00 stops the transmission - I2C bus is released.

Reading from EEPROM

Write per TCP/IP to Netzer: 0xA0 0x5C 0x00 0x73 0xA1 0x01 0x00
Answer from EEPROM received per TCP/IP from Netzer: 0xFF 0xFF 0xFF 0xFF 0x55 0x78

  1. 0xA0 is the slave address with the R/W bit cleared, means write access.
  2. Netzer answers with 0xFF, indicating the available slave.
  3. 0x5C 0x00 transfers the memory address 0 - of course must be backslashed ('\' = 0x5C)
  4. Netzer answers with 0xFF, successful transfered memory address.
  5. 0x73 initiates a repeated start on the bus.
  6. Netzer answers with 0xFF, successful repeated start.
  7. 0xA1 is the slave address with the R/W bit set, means read access.
  8. Netzer answers with 0xFF, indicating the available slave.
  9. Now the 0x01 says to Netzer: Pull me one byte from slave and acknowledge it.
  10. Netzer answers with the value read from memory address 0: 0x55.
  11. The 0 says to Netzer: Pull me one more byte from slave and stop.
  12. Netzer answers with the value read from memory address 1 (auto increment feature of the EEPROM): 0x78.
  13. Netzer automatically announces a stop condition after sending the byte.

Generated on Fri Mar 29 10:34:28 2013 for Netzer by  doxygen 1.5.5