I got a sample DS307 from Fozzy Vis today. Here's my attempt to interface it with the new hardware I2C module:
HWI2C>W
POWER SUPPLIES ON
HWI2C>p
1. Pullup off
2. Pullup on
(1) >2
PULLUP RESISTORS ON
HWI2C>v
VOLTAGE MONITOR: 5V: 4.9 | 3.3V: 3.3 | VPULLUP: 5.0 |
HWI2C>(1)
Searching 7bit I2C address space.
Found devices at:
0xD0 0xD1
HWI2C>
Turn on the power supplies, turn on the pull-up resistors, check that voltages are OK, search for I2C address.
Datasheet page 12 says the slave address is 1101000x where x is R/W. 0b11010000=0xd0, so success!
HWI2C>[0xd0 0 0]
I2C START CONDITION
WRITE: 0xD0 GOT ACK: YES
WRITE: 0x00 GOT ACK: YES
WRITE: 0x00 GOT ACK: YES
I2C STOP CONDITION
HWI2C>[0xd0 0]
I2C START CONDITION
WRITE: 0xD0 GOT ACK: YES
WRITE: 0x00 GOT ACK: YES
I2C STOP CONDITION
HWI2C>[0xd1 r:8]
I2C START CONDITION
WRITE: 0xD1 GOT ACK: YES
BULK READ 0x08 BYTES:
0x00 0x00 0x00 0x01 0x01 0x01 0x00 0x03
I2C STOP CONDITION
HWI2C>
I reset the Clock Halt (CH) bit of byte 0 to 0, enabling the clock. I then set the read/write pointer to 0 and read the 8 time-related bytes.
HWI2C>[0xd1 0x8 3 2 1]
I2C START CONDITION
WRITE: 0xD1 GOT ACK: YES
WRITE: 0x08 GOT ACK: YES
WRITE: 0x03 GOT ACK: YES
WRITE: 0x02 GOT ACK: YES
WRITE: 0x01 GOT ACK: YES
I2C STOP CONDITION
HWI2C>[0xd1 0x8]
I2C START CONDITION
WRITE: 0xD1 GOT ACK: YES
WRITE: 0x08 GOT ACK: YES
I2C STOP CONDITION
HWI2C>[0xd0 r:3]
I2C START CONDITION
WRITE: 0xD0 GOT ACK: YES
BULK READ 0x03 BYTES:
Next I wrote three bytes (3 2 1) to the RAM addresses 0x8+. Unfortunately, when I read it back the Bus Pirate freezes waiting for a reply.
So, now I'll try it with the software library at high speed.
HiZ>m
1. HiZ
2. 1-WIRE
3. UART
4. I2C
5. SPI
6. JTAG
7. RAW2WIRE
8. RAW3WIRE
9. PC KEYBOARD
10. MIDI
11. LCD
12. HWI2C
(1) >4
MODE SET
Set speed:
1. Slow(~5KHz)
2. Fast(~50KHz)
SPEED>(1) >2
I2C routines Copyright (C) 2000 Michael Pearce
Released under GNU GPL
I2C READY
I2C>W
POWER SUPPLIES ON
I2C>p
1. Pullup off
2. Pullup on
(1) >2
PULLUP RESISTORS ON
I2C>(1)
Searching 7bit I2C address space.
Found devices at:
0xD0 0xD1
I2C>
Good so far...
I2C>[0xd0 0 0]
I2C START CONDITION
WRITE: 0xD0 GOT ACK: YES
WRITE: 0x00 GOT ACK: YES
WRITE: 0x00 GOT ACK: YES
I2C STOP CONDITION
I2C>[0xd0 0]
I2C START CONDITION
WRITE: 0xD0 GOT ACK: YES
WRITE: 0x00 GOT ACK: YES
I2C STOP CONDITION
I2C>[0xd1 r:8]
I2C START CONDITION
WRITE: 0xD1 GOT ACK: YES
BULK READ 0x08 BYTES:
0x00 0x00 0x00 0x01 0x01 0x01 0x00 0x03
I2C STOP CONDITION
I2C>
Write 0 to CH bit, then reset read/write pointer and read the 8 clock-related bytes.
I2C>[0xd0 0x8]
I2C START CONDITION
WRITE: 0xD0 GOT ACK: YES
WRITE: 0x08 GOT ACK: YES
I2C STOP CONDITION
I2C>[0xd0 0x8 1 3 3 7 ]
I2C START CONDITION
WRITE: 0xD0 GOT ACK: YES
WRITE: 0x08 GOT ACK: YES
WRITE: 0x01 GOT ACK: YES
WRITE: 0x03 GOT ACK: YES
WRITE: 0x03 GOT ACK: YES
WRITE: 0x07 GOT ACK: YES
I2C STOP CONDITION
I2C>[0xd0 0x08]
I2C START CONDITION
WRITE: 0xD0 GOT ACK: YES
WRITE: 0x08 GOT ACK: YES
I2C STOP CONDITION
I2C>[0xd1 r:4]
I2C START CONDITION
WRITE: 0xD1 GOT ACK: YES
BULK READ 0x04 BYTES:
0x01 0x03 0x03 0x07
I2C STOP CONDITION
I2C>
Now, set to ram 0x08, write 1 3 3 7, read it back. All worked OK.
I2C>[0xd0 0x08 [ 0xd1 r:4]
I2C START CONDITION
WRITE: 0xD0 GOT ACK: YES
WRITE: 0x08 GOT ACK: YES
I2C START CONDITION
WRITE: 0xD1 GOT ACK: YES
BULK READ 0x04 BYTES:
0x40 0x01 0x01 0x01
I2C STOP CONDITION
I2C>
If I try a repeated start like you did, I get the wrong data. Don't know who sent what, I'll have to drag out the LA to be sure. I'm almost certain it's a problem with the library.
I2C>[0xd0 0x08] [0xd1 r:4]
I2C START CONDITION
WRITE: 0xD0 GOT ACK: YES
WRITE: 0x08 GOT ACK: YES
I2C STOP CONDITION
I2C START CONDITION
WRITE: 0xD1 GOT ACK: YES
BULK READ 0x04 BYTES:
0x20 0x01 0x00 0x90
I2C STOP CONDITION
I2C>[0xd0 0x08] [0xd1 r:4]
I2C START CONDITION
WRITE: 0xD0 GOT ACK: NO
WRITE: 0x08 GOT ACK: NO
I2C STOP CONDITION
I2C START CONDITION
WRITE: 0xD1 GOT ACK: YES
BULK READ 0x04 BYTES:
0x00 0x00 0x01 0x25
I2C STOP CONDITION
I2C>
I tried several ways to read everything in a single command, including with a delay (&:255). First time I just got the wrong values, the second time I had an ACK problem like you experienced.
For now, try read and write commands in seperate entries. In the long term, it looks like there's a bug in SW I2C and a timeout is needed in the HW I2C.