Max5135 SPI Interface problem


Just wondering if anyone might be able to shed some light on anything I should try and look at, this is the first time for me to use the SPI.

As far as I can tell I am sending the MAX5135 the correct signals but it does not update any of the DAC outputs.

I have attached a picture of the signals going to the IC. The REFI is sitting at 5V.

Blue is the LDAC line. It is a hardware line active low which tells the DAC to output the value that has been loaded into the register.

Yellow is the CS line. Again active low.

Light Blue is the data line.

Purple is the CLK.

The MAX5135 says its clocks on the high to low, MSB first. This means looking at the display the value sent in binary is “00011111”,“11111111”,“11111111”. It is a 3 byte send. First byte is the command.

The code I am using is;

#include <SPI.h>

#define CSMax5135 53 //SS for SPI to MAx5135
#define LDAC 7 // LDAC pin for the Max5135
//set data out MSB first
//set Clock Polarity High, and Clock phase low. Data is latched in on CLK going low, and CLK is held high when not in use. 
SPISettings Max5135Settings(125000, MSBFIRST, SPI_MODE2);

void setup() {
  //set the CS Line of the Max5135 to output and HIGH
  pinMode(CSMax5135, OUTPUT);
  //set the LDAC pin up
  pinMode(LDAC, OUTPUT);
  digitalWrite(LDAC,HIGH); // LDAC is active low to write values to DAC's
  //Turn on the SPI


void loop() {
  digitalWrite(CSMax5135,LOW); //Set CS to LOW to activate IC
  SPI.transfer(31);  //set out0,out1,out2,out3 as the DAC to load
  SPI.transfer(255);  //set value to max output.
  digitalWrite(CSMax5135,HIGH); //finished with max5135
  digitalWrite(LDAC,LOW); //shift data into register

If anyone can shed some light, maybe I am making a mistake in the code, as I am finding the SPI instructions a little vague.

Cheers before hand.

Max5135 SPI Signals .png

The SPI lines look good.

The control signal is not correct according to the datasheet. That needs to be a hex value.

// change this
  SPI.transfer(31);  //set out0 as the DAC to load
// to this
  SPI.transfer(0x31);  //set out0 as the DAC to load

edit: If you want to change them all,

  SPI.transfer(0x3F);  //set all as the DAC to load

edit2: After reading the datasheet and your code, if you are using the LDAC line to update all lines together, then something is not right. This should write to the input registers and a LOW pulse on the LDAC line should update them all simultaneously.
  SPI.transfer(0x1F);  //set all as the DAC to load

Hey SurferTim,

Much appreciated for the look at the datasheet and all.

I wouldn’t think that passing a hex value vs decimal should make a difference.

Your code;

  SPI.transfer(0x1F);  //set all as the DAC to load

is the same as mine;

  SPI.transfer(31);  //set all as the DAC to load

Decimal 31 = 0x1F HEX.

I did try sending a 63 (0x3F) as the command and holdling LDAC low, but it made no difference.

Now someone else has looked at the code, and it seems good, I am beginning to think the IC is faulty…I was hoping that something silly like MSB in the datasheet wasn’t the same order as MSB out the Arduino…but alas the scope says it looks OK.

I’m off to tinker with it now.

After much tinkering, I ended up replacing the IC, and the code works fine. Much appreciated for the suggestions and taking the time.

hello, I've received 4 four samples from Maxim of the max5136 and I have the same problem. I soldered in a ssop adapted so I can use it in a breadboard, but nothing happened. I wish you could read this and help me. Thanks!!


Pretty simple. SPI Mode 0, (default setting), MSB First (also default setting), 4 MHz SPI clock (default setting) or update to 8 MHz clock (SPI clock divisor changed to 2, vs default of 4).

Write to the MAX5134–MAX5137 using the following sequence:

  1. Drive CS low, enabling the shift register.
  2. Clock 24 bits of data into DIN (C7 first and D0 last), observing the specified setup and hold times. Bits D15–D0 are the data bits that are written to the internal register.
  3. After clocking in the last data bit, drive CS high. CS must remain high for 33ns before the next transmission is started.

33ns = ~1/2 clock cycle at 16 MHz, will not be an issue. digitalWrite ssPin Low for the next transfer will eat up that time.

digitalWrite (ssPin, LOW);
SPI.transfer (byte0); // control word
SPI.transfer (byte1); // data
SPI.transfer (byte2); // data
digitalWrite (ssPin, HIGH);

The MAX5134–MAX5137 3-wire serial interface is compatible with MICROWIRE, SPI, QSPI, and DSPs (Figures 2, 3). The interface provides three inputs, SCLK, CS, and DIN and one output, READY.
Use READY to verify communication or to daisy-chain multiple devices (see the READY section). READY is capable of driving a 20pF load with a 30ns (max) delay from the falling edge of SCLK.
The chip-select input (CS) frames the serial data loading at DIN.
Following a chip-select input’s high-to-low transition, the data is shifted synchronously and latched into the input register on each falling edge of the serial-clock input (SCLK).
Each serial word is 24 bits.
The first 8 bits are the control word followed by 16 data bits (MSB first), as shown in Table 1.
The serial input register transfers its contents to the input registers after loading 24 bits of data.

To initiate a new data transfer, drive CS high, keep CS high for a minimum of 33ns before the next write sequence.

The MAX5134–MAX5137 feature an active-low LDAC logic input that allows the outputs to update asynchronously. Keep LDAC high during normal operation (when the device is controlled only through the serial interface).