using i2c functions from jtag. Table 1. Function description __________________________________________________________________________________________________ C function | jtag function | description __________________________________________________________________________________________________ void i2c_init() iini \n initializes i2c connection to 1-Wire masters, resets 1-Wire masters, resets lists of found 1-Wire devices uint8 OWSearch(uint8 ad) isea ad\n C function find one 1-Wire device. If it find a new one returns 1, otherwise returns 1 jtag function makes complete search for 1 1-Wire master 'ad' is address of 1-Wire master (0-3) uint8 OWResetSearch(uint8 ad) irse ad\n Resets search results for 1-Wire master with address 'ad' uint8 OWConfT(uint8 owm, icft ad n cfg\n Configures thermometer. 'ad' is uint8 ndev, the address of 1-Wire master. uint8 conf) 'n' is the number of thermometer in the list of found thermometers on given 1-Wire master. List is constant from search to search, but physical location of this thermometer can be found only experimentally. 'cfg' is the digitization depth: 0 corresponds to 9-bit digitization 3 corresponds to 16-bit digitization uint8 OWConvertT(uint8 owm, icvt ad n\n Starts digitization for thermometer uint8 ndev) number 'n' on 1-Wire master with address 'ad'. 9-bit digitization takes ~70 ms, and 16-bit takes ~900ms uint8 OWReadT(uint8 owm, iret ad n\n Reads out digitized temperature. uint8 ndev, In current version readings are uint8* t1, printed on screen. uint8* t2) uint8 OWConfV(uint8 owm, icfv ad n\n Configures potentiometer. Since only uint8 ndev) one aplicable configuration can be used one need to specify only 1-Wire master address and number of potentiometer in the list of found potentiometers uint8 OWSetV(uint8 owm, isev ad n v\n Sets and verifies the wiper uint8 ndev, position (0-255) for potentiometer uint8 v) number 'n' on 1-Wire master with address 'ad' uint8 OWReadV(uint8 owm, irev ad n\n Reads wiper position. In current uint8 ndev, version readings are printed uint8* v); on screen. uint8 OWConfADC(uint8 owm, icfa ad n Configures ADC with number 'n' on uint8 ndev, bits range\n 1-Wire master with address 'ad'. uint8 abits, jtag function sets the same uint8 bbits, configuration for all inputs. uint8 cbits, 'bits' and 'range' must be hex numbers. uint8 dbits, 'bits' ('?bits' in C function) uint8 arange, sets the accuracy of digitization: uint8 brange, 0x01 corresponds to 1-bit digitization uint8 crange, 0x10 corresponts to 16 bit digitization. uint8 drange) 'range'('?range' in C function) sets the input voltage range: 0x00 sets the full scale to ~2.5 V 0x01 sets the full scale to ~5 V uint8 OWConvertADC(uint8 owm, icva ad n sel\n Starts the digitization for uint8 ndev, the specified ADC. 'sel' is the uint8 sel) selection of inputs to be digitized. sel=0x0F selects all inputs for digitization. To skip a channel just clear corresponding bit uint8 OWReadADC(uint8 owm, irea ad n sel\n Reads digitized values and dumps them uint8 ndev, on screen. uint8 sel) __________________________________________________________________________________________________ Table 2. Command flow __________________________________________________________________________________________________ jtag commands minicom output comment __________________________________________________________________________________________________ << iini init i2c fucntion found only one >> File stored. i2c reset 1-wire master with 03 not found address 0 and inited it 02 not found 01 not found 00 found 1w configuration written inited i2c << isea 0 20 F0 8D 05 00 00 00 3B search for 1-wire devices >> File stored. 20 FA AC 08 00 00 00 5C on 1-wire master with 28 75 9F B2 00 00 00 23 address 0. it dumps 28 5D 9F B2 00 00 00 34 serial numbers of 2C A8 D7 08 00 00 00 04 found devices on sreen 3A 65 9F 00 00 00 00 6F 3A 9F AC 00 00 00 00 18 << icfv 0 0 i2c_ConfV: configuration is good configure first >> File stored. i2c_ConfV: configuration is written potentiometer on 1-wire master with address 0. << isev 0 0 63 i2c_setV: wiper position is good sets and verifies >> File stored. i2c_setV: wiper position is written wiper position << irev 0 0 OWReadV: wiper position 3F reads wiper position >> File stored. << icft 0 0 3 configure first >> File stored. thermometer for 16-bit digitization << icft 0 1 0 configure second >> File stored. thermometer for 9-bit digitization << icvt 0 1 start digitization >> File stored. for the second thermometer << icvt 0 0 start digitization >> File stored. for the first thermometer << iret 0 0 temperature: first two bytes >> File stored. 57 01 60 20 7F FF 09 10 04 give the temperature reading. MSB is '01', LSB is '57'. See below how to convert them to degrees. << iret 0 0 temperature: temperature is "01 57" 5A 01 60 20 5F FF 06 10 10 << icfa 0 0 0x0A 0x01 Configures ADC >> File stored. << icva 0 0 0x0F starts digitization >> File stored. for all ADC channels << irea 0 0 0x0F ADC: reads converted >> File stored. 08 C2 00 00 00 00 00 00 DC 25 voltages. first line 0A 01 0A 01 0A 01 0A 01 C7 54 contains 4x2 bytes 00 FF 00 FF 00 FF 00 FF 94 94 of data + 2 bytes of CRC 00 00 00 00 40 00 00 00 EA 3F LSB comes first for channel D converted value is 0xC208 ___________________________________________________________________________________________________ Temperature conversion: MSB bit 7 6 5 4 3 2 1 0 value s s s s 128 64 32 16 LSB bit 7 6 5 4 3 2 1 0 value 8 4 2 1 0.5 0.25 0.125 0.0645 where s is the sign '5A 01' will read as 16+4+1+0.5+0.125 = 21.6125 C ___________________________________________________________________________________________________ ADC conversion Least significant byte comes first '08 C2' will read as 0xC208 = 49672 a.u. 1 a.u corresponds to ~6e-05 counts/V this reading is approximately equal 2.99 V