ABOUT THE I2C BUS
The PCF8582 EEPROM chip on board the TDS9092 is one of a number of available devices which will hang on the same 2-wire bus. These I2C devices are made by Philips, Xicor, Microchip Technology and others. They can be a few meters from the computer board without having to add buffers.
The TDS9092 drives these devices at a speed of about 17K baud. Transfers are synchronous and handshaken. The Forth words not only handle the data but also return a flag which is only true if the transfer actually happened.
In practice you are only likely to need the words I2C! and I2C@ , the write and the read instructions, but the primitives from which they are constructed are made available since they enable you to use other modes in I2C peripherals, such as automatic internal address increment.
Each I2C chip has different possible chip addresses determined by the type of chip it is. For example the PCF8582 has addresses hex 50 and 57, and on the TDS9092 it is connected at address hex 50. Within each chip are several internal addresses which have nothing to do with the first one. In the case of the PCF8582 these are 00 to FF and each represents one byte of EEPROM. You can employ these as non-volatile memory.
Note that neither of these two addresses are the same as the microprocessor address space - that is something else again!
For example, to store 17 to address FF in the on-board EEPROM chip:
$17 $FF $50 I2C!
A 1 will be left on the stack if the transfer is successful, which it should be. Try device address $51 and you will find the transfer fails because there is no IC at that address. Recover the data like this:
$FF $50 I2C@
This leaves on the stack the validation flag with the data fetched underneath. Transfer times are of the order of 1 to 2 ms. After each byte using the on-board EEPROM you should wait for 50ms to allow the device to complete the erase and write. Reading needs no such delay. The EEPROM data shows a maximum of 10000 write cycles for each byte, and data retention of 10 years minimum. Other I2C chips can be added externally.
Although I2C! and I2C@ are the main words for use with I2C devices, it may be necessary to make up others from the primitives STARTI2C STOPI2C R1BYTE S1BYTE R1BIT .
When using I2C words on the TDS9092 the spare bits P50 to P55 should preferably be used as inputs since the I2C words have to change the Data Direction Register of port 5, and the unused bits are always afterwards set to 0 (for input).