DS1077 I2C on Panda II

Hi Guys,

I wonder if someone can point out my mistake. I am trying to use I2C to communicate. My Master is the Panda II and Slave is DS1077 Programmable Oscillator.

DS1077 Datasheet: https://www.sparkfun.com/datasheets/Components/SMD/DS1077.pdf


// I2C Command Write Buffer
private static byte[] I2CDeviceTXD = new byte[] { 0x01, 0xFF, 0xC0 };

// I2C Read Buffer
private static byte[] I2CDeviceRXD = new byte[2];

private static ushort BUS = 0x0B;
private static ushort DIV = 0x01;
private static ushort MUX = 0x02;
private static ushort E2 = 0x3F;

// private Register TWCR = null;
private static ushort I2CDeviceBus = BUS;
private static int I2CDeviceClock = 400;

private static I2CDevice I2CDev;
private static I2CDevice.Configuration I2CConf = new I2CDevice.Configuration(I2CDeviceBus, I2CDeviceClock);

private static I2CDevice.I2CReadTransaction I2CRead;
private static I2CDevice.I2CWriteTransaction I2CWrite;

public static void Transact()
{
I2CDev = new I2CDevice(I2CConf);

I2CWrite = I2CDevice.CreateWriteTransaction(I2CDeviceTXD);
I2CRead = I2CDevice.CreateReadTransaction(I2CDeviceRXD);

I2CDevice.I2CTransaction[] xActions = new I2CDevice.I2CTransaction[] { I2CWrite, I2CRead };

if (I2CDev.Execute(xActions, 1000) == 0)
{
Debug.Print("Transaction Failed!");
}
else
{
Debug.Print("Transaction Success!");
}

Debug.Print("Buffer Length: " + I2CRead.Buffer.Length.ToString());

Debug.Print("Buffer Value: " + I2CRead.Buffer[0].ToString());
}

My Panda Is using firmware version: 4.1.8.0 and NETMF is 4.1. Any Ideas?

I feel my problem is some sort of addressing problem. I get the message “Transaction Failed!” because the transaction is returning 0.

Thanks

[EDIT] : I should point out, I have been reading this: Parts: 133MHz-16.2kHz Programmable Oscillator (DS1077) | Hackaday

It is an excellent article but I am no further ahead.

What are your address line settings?

You are addressing the device here:

I2CConf = new I2CDevice.Configuration(I2CDeviceBus, I2CDeviceClock);

And these two:

private static ushort BUS = 0x0B;
private static ushort I2CDeviceBus = BUS;

So you’re not addressing this device correctly - the device address (in 7-bit nomenclature) is 1011xxx, where the XXX is A2, A1, A0 in order. If they’re all grounded, then it’s address would be 0x58.

@ Brett - Thanks for your answer Brett. Any chance of explaining a little more?

I used:


private static ushort I2CDeviceBus = 0x58;
private static int I2CDeviceClock = 100;

private static I2CDevice.Configuration I2CConf = new I2CDevice.Configuration(I2CDeviceBus, I2CDeviceClock);

Unfortunately I still have a problem.

Thanks, ChrisO

I needed to also change the clock:



private static ushort I2CDeviceBus = 0x58;
private static int I2CDeviceClock = 400;

private static I2CDevice I2CDev;
private static I2CDevice.Configuration I2CConf = new I2CDevice.Configuration(I2CDeviceBus, I2CDeviceClock);


Thanks Brett, you’re a champion!

I’m surprised that running at a slower clock speed made a difference; although this device may be sensitive to that (you could check the datasheet if you wanted)

I2C is described https://www.ghielectronics.com/docs/12/i2c and is really the key here. I2C addresses are always represented as a 7-bit address, whereas many places (like the bus pirate example you showed from HaD) explain them with TWO full 8-bit addresses, one for reading and one for writing - while technically correct when considered from a bit-banging perspective or from a logic analyser, the abstraction layer should always represent this as the 7-bit address without the R/W bit. Checking the datasheet showed me the address should be the bit pattern I showed earlier, and you simply omit the 8th read/write bit. That’s how I established that 0x58 would be one of the possible addresses (the “default” if no address lines on the chip are tied high).

Hope that description helps.