The infamous Max 6954

Ok, I'm stumped...

I have read around on the forums for the answer to this, and I cannot find it.

I have the MAX6954 setup on a SPI collection on the UNO R3.

I have modified the digitalPot example, so that I could use the easy way to write the address and the command.

At the moment I want to send the command to test all the segments of the 16- segment displays.

Withthe help of Mixed-signal and digital signal processing ICs | Analog Devices, I have got the following code

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


// set pin 10 as the slave select for the digital pot:
const int slaveSelectPin = 10;

void setup() {
  // set the slaveSelectPin as an output:
  pinMode (slaveSelectPin, OUTPUT);
  // initialize SPI:
  SPI.begin(); 
  
  digitalPotWrite(0x07, 0x01);
}

void loop() {
  digitalPotWrite(0x07, 0x01);
  digitalPotWrite(0x02, 0xff);

}

int digitalPotWrite(int address, int value) {
  // take the SS pin low to select the chip:
  digitalWrite(slaveSelectPin,LOW);
  //  send in the address and value via SPI:
  SPI.transfer(address);
  SPI.transfer(value);
  // take the SS pin high to de-select the chip:
  digitalWrite(slaveSelectPin,HIGH); 
}

I have tried playing with SPI.setBitOrder() and set MSBFIRST, and LSBFIRST

I have also played with SPI.setMode(), and gone through all of the options...

All of which give nothing on the display., although I have noticed that the mode 3 gives the led on pin 13 lit all of the time dimley.

Has anyone got any ideas on this one?

Everything appears to be wired correcly.

I have also added an LED to the DOUT and it looks like there is output coming through the registers.

I have a serial dump of the address and values which gives me

7 -1
2 - 255

is there any way I can se the binary representation of what is being transfered?

Many thanks

Jimmy

Hi,

Well I have got it going to some extent, I can now get it to updat 90% of the time, but there does appear to be slight glitch every so often when it issues out commands.

I think this will be down to the max chip not being 100% spi compatible despite what they say.

From what I have read online, these thinks are hard to get working correctly and they will not give the display due to having to take the CS low halfway through a clock pulse.

This is what got me going

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


// set pin 10 as the slave select for the digital pot:
const int slaveSelectPin = 10;


void setup() {
 
  // set the slaveSelectPin as an output:
  pinMode (slaveSelectPin, OUTPUT);
  Serial.begin(9600);
  // initialize SPI:
  SPI.begin(); 
  SPI.setBitOrder(MSBFIRST);
  SPI.setDataMode(SPI_MODE2);
  SPI.setClockDivider(SPI_CLOCK_DIV16); // 2,4,8,16,32,64,128
  
  push(0x07, 0x01);
  delay(1000);
  push(0x07, 0x00);
  delay(100);
  push(0x04, 0x01);
  push(0x03, 0x01);
  push(0x02, 0x0f);

}

void loop() {

  if(Serial.available()) {
    byte incoming = Serial.read();
    push(0x20, incoming);
  }
}

int push(int address, int value) {
  // take the SS pin low to select the chip:
  //digitalWrite(13, LOW);
  //delay(10);
  digitalWrite(slaveSelectPin,LOW);
  //  send in the address and value via SPI:
  SPI.transfer(address);
  SPI.transfer(value);
  // take the SS pin high to de-select the chip:
  digitalWrite(slaveSelectPin,HIGH); 
  //delay(5);
  //digitalWrite(13, HIGH);
}

Hope this is of help to someone...

I will also try a bitbang method now to get 100% working

manicmoddin:
I will also try a bitbang method now to get 100% working

Hi manicmoddin!

Did you get somewhere with the MAX6954 using bit-banging?

I'm also kind of stuck with this IC on the Arduino Due.

Thanks

This is not correct.

SPI.setDataMode(SPI_MODE2);

That device is MSBFIRST and SPI mode 0. CLK LOW with HIGH pulses (CPOL=0) and capture on the first (rising) edge (CPHA=0).
http://datasheets.maximintegrated.com/en/ds/MAX6954.pdf
Page 9.

The Due has its own SPI stuff that seems different from the other Arduinos. That may be a thread for the Due section.
http://forum.arduino.cc/index.php?board=87.0

If the device has problems, I usually use a "delayMicroseconds(1);" after setting the slave select to LOW and before starting the first transfer. Sometimes these devices don't get ready as fast as you think.

Hi all,

i know is resorecting an old thread, but finally I had need to try and work with this again.

I ordered new samples from Maxim, and ran the code above, but too out the spimode and the clock divide, and it runs 100% smooth now.

Not sure where the problem was with the thing last time around, but now am working with these things fine.

I'm going to create a library for this the best I can (will be my first), but will give an insight as how I got things working.

Will post links on here once done.

Jimmy

I seemingly have very similar code to yours, yet I can not get the Max6854 to respond at all. I can't figure out what you did differently.

I mean reading your code, it looks like the slaveSelectPin should bull pulled high after the last clock cycle still, which causes the problem in the first place.

EDIT. If anyone knows of any competitor LED driver chips that are pin compatible with the MAX6954, I'd love to know.

EDIT2:
Here is at least some bit banging for communicating to this thing.

//Pin mapping for ATTiny167
#define CS1        14  // MAX6954 1
#define DATAOUT    11 // MOSI
#define DATAIN     12 // MISO
#define CLK        13 // sck

byte DECODE = B00000001;
byte INTENSITY = B00000010;
byte ScanLIMIT = B00000011;
byte DigitTYPE = B00001100;
byte CONFIGURATION = B00000100;

void setup() {
  pinMode(DATAOUT, OUTPUT);
  pinMode(DATAIN, INPUT);
  pinMode(CS1, OUTPUT);
  pinMode(CLK, OUTPUT);

  digitalWrite(CS1, HIGH);
  digitalWrite(DATAIN, HIGH);
  delay(5000);

  send_first_8(DECODE);
  send_seccond_8(0xFF);

  delay(100);

  send_first_8(ScanLIMIT);
  send_seccond_8(0x07);

  delay(100);

  send_first_8(DigitTYPE); //14 SEGMENT DISPLAY
  send_seccond_8(0xFF);

  delay(100);

  send_first_8(CONFIGURATION); //Exit shutdown mode, disable blinking, global intensity
  send_seccond_8(0x01);

  delay(100);

  send_first_8(INTENSITY); //BRIGHTNESS OF LEDS
  send_seccond_8(0x1F);

  delay(100);

}

void loop() {
  send_first_8(0x21); //2ND LED. 
  send_seccond_8(0x41); //"A"
  delay(1000);
  send_first_8(0x21); //2ND LED
  send_seccond_8(0x4D); //"M"
  delay(1000);
}

/*FUNCTIONS*/

void chip_select_low(void) {
  digitalWrite(CS1, LOW);
}

void chip_select_high(void) {
  digitalWrite(CS1, HIGH);
}

void sclk() {
  digitalWrite(CLK, HIGH);
  digitalWrite(CLK, LOW);
}


void send_first_8(char data) {
  char abit;
  char index;
  chip_select_low();
  for (index = 7; index >= 0; index--) {
    abit = ((data >> index) & 0x01);
    if (abit == 1)
    {
      digitalWrite(DATAOUT, HIGH);
      sclk();
    } else {
      digitalWrite(DATAOUT, LOW);
      sclk();
    }
  }
}

void send_seccond_8(char data) {
  char abit;
  char index;
  for (index = 7; index >= 0; index--) {
    abit = ((data >> index) & 0x01);
    if (abit == 1)
    {
      digitalWrite(DATAOUT, HIGH);
    } else {
      digitalWrite(DATAOUT, LOW);
    }
    if (index == 0) {
      digitalWrite(CLK, HIGH);
    } else {
      sclk();
    }
  }
  chip_select_high();
  digitalWrite(CLK, LOW);
}