Teensy 2++ and AD5293 DigiPot

Status
Not open for further replies.

hematec

New member
[SOLVED] - Teensy 2++ and AD5293 DigiPot

Hi @all,

i'm currently working on a Project using the AD5293 DigiPot (http://www.analog.com/en/digital-to-analog-converters/digital-potentiometers/ad5293/products/product.html).

I connected the Teensy 2++ as followed:

Teensy 2++ <-> AD5293
B0 <-> SYNC (12)
B1 <-> SCLK (11)
B2 <-> DIN (10)

I'm using the following arduino code:
Code:
const byte AD_CS_PIN = 20;

// transfer 0x1802 to enable write to RDAC register
digitalWrite(AD_CS_PIN,LOW);
SPI.transfer(0x18);
SPI.transfer(0x02);
digitalWrite(AD_CS_PIN,HIGH);

// Transfer 0x500 to set to 1/4 full-scale
digitalWrite(AD_CS_PIN,LOW);
SPI.transfer(0x05); // 1/4 fullscale
SPI.transfer(0x00);
digitalWrite(AD_CS_PIN,HIGH);

// give some time
delay(2000);

// set to full-scale (1023)
digitalWrite(AD_CS_PIN,LOW);
SPI.transfer(0x07); // 1/4 fullscale
SPI.transfer(0xFF);
digitalWrite(AD_CS_PIN,HIGH);

The Bit order is MSB first.

I really could not get this piece of code working and would appreciate any helpfull hinds!

BTW: SPI is working. I checked with AD5206 without any Problems.

Thx a lot.
 
Last edited:
i finally got it working!!

The magic is that the AD5293 uses SPI Mode 1 (CPOL=0, CPHA=1).
So i simply had to add
Code:
SPI.setDataMode(SPI_MODE1);

Finally the working code Looks as followed:
Code:
const byte AD_CS_PIN = 20;

//Start SPI Stuff
pinMode(AD_CS_PIN,OUTPUT); // SPI - CS
SPI.begin();
SPI.setBitOrder(MSBFIRST);
SPI.setClockDivider(SPI_CLOCK_DIV2);
SPI.setDataMode(SPI_MODE1);

// transfer 0x1802 to enable write to RDAC register
digitalWrite(AD_CS_PIN,LOW);
SPI.transfer(0x18);
SPI.transfer(0x02);
digitalWrite(AD_CS_PIN,HIGH);

// Transfer 0x500 to set to 1/4 full-scale
digitalWrite(AD_CS_PIN,LOW);
SPI.transfer(0x05); // 1/4 fullscale
SPI.transfer(0x00);
digitalWrite(AD_CS_PIN,HIGH);

// give some time
delay(2000);

// set to full-scale (1023)
digitalWrite(AD_CS_PIN,LOW);
SPI.transfer(0x07); // 1/4 fullscale
SPI.transfer(0xFF);
digitalWrite(AD_CS_PIN,HIGH);
 
Glad you got it.

I've seen very few chips that use modes other than 0 or 3, so this would have been pretty much my last guess.
 
Status
Not open for further replies.
Back
Top