Using SPI to interface with MAX1257 (Multi channel Data converter)

Hi All

I was hoping someone might be able to shed some light for me with using an Arduino Due with Maxim MAX1257 chip (MAX1257 12-Bit, Multichannel ADCs/DACs with FIFO, Temperature Sensing, and GPIO Ports | Analog Devices). It is quite a capable device but I am not having much luck interfacing to it.

Looking at the timing on an oscilloscope it looks to me as though the timing and bit sequence is correct however I can't seem to enable and set the registers for the DAC.

If any one has any familiarity with the device (or family of devices) and knows off hand what the issue is I would be most appreciative. Probably missing setting a register or the like

/*
  MAX1257 Control
  
  This will attempt to control MAX1257 via SPI
 
*/


// include the SPI library:
#include <SPI.h>



const int slaveSelectPin = 52;

void setup() {


  Serial.println("Set up SPI");
  // set the slaveSelectPin as an output:
  pinMode (slaveSelectPin, OUTPUT);
 
  // initialize SPI:
  SPI.begin(slaveSelectPin); 
  SPI.setDataMode(slaveSelectPin, SPI_MODE2);
  SPI.setBitOrder(slaveSelectPin, MSBFIRST);
  SPI.setClockDivider(slaveSelectPin, 21);

  Serial.println("SPI Setup Complete\n");


  //Send setup bits to MAX1257
  //DAC Select (Table 1)
  //Turn on DACs (Table 21)
  SPI.transfer(slaveSelectPin,0b00010000,SPI_CONTINUE); //DAC Select
  SPI.transfer(slaveSelectPin,0b1111111,SPI_CONTINUE);  //Turn on DAC 7-4
  SPI.transfer(slaveSelectPin,0b11110011);              //Turn on DAC 3-0

  delay(2); //Delay 2ms

  //Send DAC Select (Table 1)
  //Send data to DAC (Table 20)
  SPI.transfer(slaveSelectPin,0b00010000,SPI_CONTINUE); //DAC Select
  SPI.transfer(slaveSelectPin,0b10101000,SPI_CONTINUE); //Load input registers and DA outputs (Should set halfway to 0b1000000)
  SPI.transfer(slaveSelectPin,0b00000000);

    
}

void loop() {


}

raydiator:
Hi All

I was hoping someone might be able to shed some light for me with using an Arduino Due with Maxim MAX1257 chip (MAX1257 Datasheet and Product Info | Analog Devices). It is quite a capable device but I am not having much luck interfacing to it.

Looking at the timing on an oscilloscope it looks to me as though the timing and bit sequence is correct however I can't seem to enable and set the registers for the DAC.

If any one has any familiarity with the device (or family of devices) and knows off hand what the issue is I would be most appreciative. Probably missing setting a register or the like

 // Try this in your setup()

SPI.transfer(slaveSelectpin,0B00010000,SPI_CONTINUE); // DAC Select
SPI.transfer(slaveSelectpin,0B00010000,SPI_CONTINUE); // Set all registers to 0; {table 20}
SPI.transfer(slaveSelectpin,0B00000000); // Set all registers to 0;

SPI.transfer(slaveSelectpin,0B00010000,SPI_CONTINUE); // DAC Select
SPI.transfer(slaveSelectpin,0B11101111,SPI_CONTINUE); // Transfer Registers values {table 20}
SPI.transfer(slaveSelectpin,0B11110000);                       // to all DAC's (1 for 1)

SPI.transfer(slaveSelectpin,0B00010000,SPI_CONTINUE); // DAC Select
SPI.transfer(slaveSelectpin,0B11111111,SPI_CONTINUE); // Power up all DAC's ,{table 21}
SPI.transfer(slaveSelectpin,0B11110010);                       // 

Delay(1000);

SPI.transfer(slaveSelectpin,0B00010000,SPI_CONTINUE); // DAC Select
SPI.transfer(slaveSelectpin,0B00011000,SPI_CONTINUE); // Set all registers to 0xFFF; table 20
SPI.transfer(slaveSelectpin,0B00000000); 

SPI.transfer(slaveSelectpin,0B00010000,SPI_CONTINUE); // DAC Select
SPI.transfer(slaveSelectpin,0B11101111,SPI_CONTINUE); // Transfer Register value to DAC,table 20
SPI.transfer(slaveSelectpin,0B11110000);                       //

Chuck.

Thanks Chuck.

Getting close. The ports now change state but they aren't jumping from 0x00 to 0xFF. Both jump to a single state and it occurs slightly after the last CLK signal.

I will keep trying as now it appears the part is alive but have to just give it the right instructions

Edit: DAC power up and DAC power down seem to work. Setting DAC values seems to be the issue.

Hi Chuck

Figured it out. The setup register :slight_smile:

Thanks again