AD5254 Digital Potentiometer

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
rp181
Respected Member
Posts: 395
Joined: Tue May 18, 2010 12:25 am

AD5254 Digital Potentiometer

Post by rp181 »

I am trying to get my XC-1A devkit to talk to the AD5254 digital Potentiometer, which is an I2C based chip. I have never successively used I2C on the XMOS (which is why I tend towards SPI...), and am stumped on what else to try. Everything I tried thus far invokes no response from the chip (in resistance, or an attempt to read back information). The datasheet for the AD5254:

http://www.analog.com/static/imported-f ... 3_5254.pdf

AD0 and AD1 are grounded, so the device address should be 0b1011000 (can anyone check this?)

I am using the I2C 2.0.0 module, module_i2c_master. Using this doesn't do anything:

Code: Select all

i2c_master_write_reg(0b1011000, 0, data, 1, i2c);
Using the Saleae Logic Analyzer (24 MHz sampling), I get this:
Image

Which looks completely wrong. I realize this might be due to the low sampling rate of the USB logical analyzer, so I am going to try and get a capture off of my 100 Mhz scope (probably be at least 2 Gsps).

Any help would be fantastic!

EDIT: I'm also not quite sure about the WP pin. As I understand it, it should be tied high to enable full R/W access, correct?


User avatar
Berni
Respected Member
Posts: 363
Joined: Thu Dec 10, 2009 10:17 pm

Post by Berni »

Yes you have the address right and the WP should be set to 1 for it to work.

No need to put your scope at that since from what the logic analyzer shows that is clearly not working I2C. I prefer to use SPI too since its faster, more reliable and easier to use. From my experience the librarys XMOS provides are not very good at all. So one way to go at it is to write your own bit banged I2C master(Master is a lot easier to implement than slave)

Oh and one silly question, do you have appropriate pullup resistors on SDA and SCK?
User avatar
rp181
Respected Member
Posts: 395
Joined: Tue May 18, 2010 12:25 am

Post by rp181 »

No, I do not have pull up resistors. Is this a general I2C thing, or am I missing something in the datasheet? I will add them and try bit banging it after reading up some more on I2C. Thank you!
User avatar
Bianco
XCore Expert
Posts: 754
Joined: Thu Dec 10, 2009 6:56 pm

Post by Bianco »

rp181 wrote:No, I do not have pull up resistors. Is this a general I2C thing, or am I missing something in the datasheet? I will add them and try bit banging it after reading up some more on I2C. Thank you!

Pull-up resistors are mandatory to get I2C working. The bus is open-drain driven.
See the datasheet on page 27, they use 22K.
User avatar
rp181
Respected Member
Posts: 395
Joined: Tue May 18, 2010 12:25 am

Post by rp181 »

Success! I had 3 problems:

1) Pull-up Resistors. I added the 22k resistors so the lines are default high. Turns out the I2C library was seeing that it wasn't being pulled up and terminated transmission.

2) The address needed to be 0b101100, as the library automatically puts the R/W bit.

3) I may have forgotten to connect GND on the logic analyzer...

Thanks for your help!