RS-232 to I2C/SPI/1-Wire Translator
You just got that hot new chip on Ebay and have tracked down the specifications in a (poorly translated) PDF file. Now, you try writing some code to make that puppy work. Initializations are usually the hardest part --- there are just so many variations.
Write code, assembler code, program micro, run code, scratch head, repeat...
This device lets you connect to the chip from a terminal program in your computer. You send it hex bytes, you read back hex bytes. It takes only seconds to try stuff out. The internal structure of some devices may be very complex, but it all comes down to bytes-in, bytes-out. That is all you really need to do to work out the code.
Here are the commands at your disposal:
XX - any hex byte is sent by default, up to 20 at a time.
.ddd - 1-256 hex bytes are read back.
/ - generate START condition for I2C, Chip Select for SPI, Reset for 1-Wire.
If this command is used in I2C mode, a STOP condition is automatically generated at the end of the command line. For SPI mode, a chip de-select is automatically generated.
Wddd - wait for 1-255 milliseconds.
Additionally, these commands change the operating mode. Enter them by themselves and the prompt will you get will show the change of mode.
@ - change from I2C to SPI to 1-Wire and back to I2C.
* - reverse/unreverse direction of bit transfers (read and write)
This command works only in I2C mode. It returns the read and write addresses.
S - scan all 256 possible I2C addresses
Full line buffering with backspacing is supported. Be sure to enter all hex bytes as 2 hex digits (spacing between bytes is optional). Decimal values may be entered as 1-3 digits. If you specified reverse bit mode with the '*' command, it will be indicated in front of the prompt.
Set your terminal program for normal CR and LF processing, 9600 baud no handshake. The Scan command depends on this by rewriting data on the same line (issuing CR with no LF) until an address match is found.
Here are some examples:
I2C>/A0 0020 11 22 33 (write hex values 11,22,33 to eeprom location 20).
*SPI>/11 22 33 (write to non standard SPI device with reverse bits)
ONE>/CC44 W5 /CCBE.8 (read scratch data from DS18B20 temperature sensor)
In I2C mode, besides returning hex bytes, the translator also returns either '!' for ACK's or "-" for missing ACK's.
When providing power to the target, this device supports both 5 volt and 3.3 volt devices. A 2-pin jumper on J3 selects voltage (center pin to outside pin). When running at 3.3 volts, the PIC16F616 itself runs on that voltage so the signal levels will match.
The 6 pin connector provides the following signals:
For 1-wire devices, the PIC provides up to 20ma for parasitic power on data line.
The clocking of the translator is deliberately slow for I2C and SPI to show up well on a scope if you need to. Since the protocols are synchronous (clocked), this doesn't matter. The 1-Wire protocol meets the timing specifications for such devices. This protocol has very wide margins because most of these are internally timed.
Note: The RED led must be red! It is used for its voltage drop value. Other led's may be any color.