Go Down

Topic: Maxim MAX5500 DAC with SPI (Read 2462 times) previous topic - next topic

Adion

I'm trying to use the MAX5500 with Arduino, but so far it doesn't work.

Here's the code I tried:
Code: [Select]
  //spi
  digitalWrite(chipSelectPin, LOW);
  int dac1 = 4095;
  dac1 += 3 << 12; //3 = 0011 -> load input A, update DAC
  SPI.transfer(dac1 >> 8);
  SPI.transfer(dac1 & 255);
  digitalWrite(chipSelectPin, HIGH);

If I understand the data sheet correctly, this should set output A to its max value, but it remains at 0V together with the other outputs.

Does anyone know if there's anything else that needs to be setup in order to make this work?

CrossRoads

#1
Apr 27, 2011, 09:42 pm Last Edit: Apr 27, 2011, 09:45 pm by CrossRoads Reason: 1
You are not sending nearly enough data over:
"The serial input word consists of
two address bits and two control bits followed by 12
data bits (MSB first), as shown in Figure 4."
Each SPI.transfer sends out 1 byte - so you will need 6 4 bytes.

How are the other controls wired up on the chip?
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Adion

16 bits are 2 bytes, and I'm sending 2 8-bit values.
The first 4 bits are set to 0011 using "dac1 += 3 << 12;"
The other 12 bits are set to one with "dac1 = 4095"
"dac1 >> 8" should send the most significant byte, and "dac & 255" the least significant byte.

CrossRoads

"Sends and receives a byte from the SPI bus.
Example:
n = Spi.transfer(0x2A);            // sends the byte 0x2A"

You need 4 spi.transfer calls to send 4 bytes of data.
You must send the data bytes out also even if they are don't cares - the data sheet says 4 bytes all the time.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Adion

I read the datasheet again, but I don't see where it says to send out 4 bytes.

I only find these references to 16-bit:
"The serial input word consists of two address bits and two control bits followed by 12 data bits (MSB first)"
(2+2+12=16 bits = 2 bytes)
"The MAX5500/MAX5501 require 16 bits of serial data."
"Data is sent MSB first and can be sent in two 8-bit packets or one 16-bit word"

CrossRoads

Yeah, you're right, I was misreading that.

Try a simpler set up to start:
Code: [Select]

high_btye = 0x3F;
low_byte = 0xFF;
digitalWrite(chipSelectPin, LOW);
  SPI.transfer(high_byte);
  SPI.transfer(low_byte);
  digitalWrite(chipSelectPin, HIGH);


sometimes the complex directions within directions don't work.
If that works, just manipulate the variables outside of the transfer command.

How is this pin wired?
Pin 6, REFAB, DAC A/DAC B Reference Voltage Input
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up