Go Down

Topic: help interfacing with max6960 led matrix (Read 1 time) previous topic - next topic

eddgaar

Anybody successuful interfacing themax6960 led matrix driver with arduino?
http://www.maxim-ic.com/quick_view2.cfm/qv_pk/4910

Could you please share your code?

Thanks in advance!

eddgaar

OK, I did some research, wrote my own code, and it works!
It´s a simple example of using Arduino to talk to the MAX6960  

Code: [Select]
#define DATAOUT 11//MOSI
#define DATAIN  12//MISO
#define SPICLOCK  13//sck
#define SLAVESELECT 10//ss
#define RESET 9 //reset

byte clr;

void setup()
{
 pinMode(DATAOUT, OUTPUT);
 pinMode(DATAIN, INPUT);
 pinMode(SPICLOCK,OUTPUT);
 pinMode(SLAVESELECT,OUTPUT);
 pinMode(RESET,OUTPUT);

 // SPCR = 01010000
 //interrupt disabled,spi enabled,msb 1st,master,clk low when idle,
 //sample on leading edge of clk,system clock/4 rate (fastest)
 SPCR = (1<<SPE)|(1<<MSTR);
 clr=SPSR;
 clr=SPDR;
 delay(10);

 digitalWrite(SLAVESELECT,HIGH);  
 digitalWrite(RESET,HIGH);
 delay(5);  
 digitalWrite(RESET,LOW);
 delay(5);
 digitalWrite(RESET,HIGH);
 delay(200);
 //configurar registros aquí

//Panel Configuration Register
 digitalWrite(SLAVESELECT,LOW);
 spi_transfer(0x0d);
 spi_transfer(0x01);  
 digitalWrite(SLAVESELECT,HIGH);
   
//Panel Intensity Register    
 digitalWrite(SLAVESELECT,LOW);
 spi_transfer(0x02);
 spi_transfer(0x30);  
 digitalWrite(SLAVESELECT,HIGH);
 
//Number of Cascaded Devices Register  
 digitalWrite(SLAVESELECT,LOW);
 spi_transfer(0x0e);
 spi_transfer(0x03);  
 digitalWrite(SLAVESELECT,HIGH);

//Number of Display Rows Register  
 digitalWrite(SLAVESELECT,LOW);
 spi_transfer(0x0f);
 spi_transfer(0x01);  
 digitalWrite(SLAVESELECT,HIGH);

 delay (500);

 digitalWrite(SLAVESELECT,LOW);
 spi_transfer(0x00);
 spi_transfer(0x00);
 spi_transfer(0x88);  
 digitalWrite(SLAVESELECT,HIGH);
while (1)
 {
 };
}

char spi_transfer(volatile char data)
{
 SPDR = data;                    // Start the transmission
 while (!(SPSR & (1<<SPIF)))     // Wait for the end of the transmission
 {
 };
 return SPDR;                    // return the received byte
}

void loop()
{
while (1);
 {
 };
}

ritzdank

#2
Nov 27, 2008, 05:07 pm Last Edit: Nov 27, 2008, 06:25 pm by ritzdank Reason: 1
Thanks for sharing the code!

I have tried to communicate with MAX6963 but to no avail. Do you actually know the difference between MAX6960/1/2/3 ?

One important thing when hooking it up to the Arduino is that you should put voltage dividers on all lines going to the MAX6960 since it runs on 3.3 volts! Signals going back to the Arduino are being interpreted correctly since +3.3 equals 1 also for the Arduino.

Did you work further on your code? As far as i can tell you are just initializing the chip. How would you actually light up the LEDs??

Would be good to receive also something from the chip itself.. like the device id for example:

Code: [Select]
uint8_t devid = (read16(0x8500) & 0x60) >> 5;

Thanks for your help
bye

eddgaar

I have tried to communicate with MAX6963 but to no avail. Do you actually know the difference between MAX6960/1/2/3 ?

I´m using the eval board from maxim.
From the manual:
The MAX6963 drives monocolor displays with two-step
intensity control. The MAX6962 drives monocolor displays
with two-step or four-step intensity control. The MAX6961
drives monocolor or RGY displays with two-step intensity
control. The MAX6960 drives monocolor or RGY displays
with two-step or four-step intensity control.


One important thing when hooking it up to the Arduino is that you should put voltage dividers on all lines going to the MAX6960 since it runs on 3.3 volts! Signals going back to the Arduino are being interpreted correctly since +3.3 equals 1 also for the Arduino.


oops, I didn´t consider the voltage levels,,,,however it works on 5v levels basis,,,, may be not for much time  ;)
I´m gonna add the dividers,,,,


Did you work further on your code? As far as i can tell you are just initializing the chip. How would you actually light up the LEDs??


I forgot to comment in the code the last write, but in fact, the last one, is a writing to light up two leds:
Code: [Select]

 //light up two leds, the first and the fifth, of the first row of the matrix
 digitalWrite(SLAVESELECT,LOW);
 spi_transfer(0x00);
 spi_transfer(0x00);
 spi_transfer(0x88);
 digitalWrite(SLAVESELECT,HIGH);


We have another version to write the entire four matrix of the evaluation board.  Its just a while cycle, who receives data from the serial port, and, write to the correspondent address of the max6960.

Regards,,,

ritzdank

Hi Eeddgar,

Quote
I´m using the eval board from maxim.


O.k. So, now i understand why you are setting up 4xMax6960 in the Cascaded Device Register.

Code: [Select]
//Number of Cascaded Devices Register
 digitalWrite(SLAVESELECT,LOW);
 spi_transfer(0x0e);
 spi_transfer(0x03);
 digitalWrite(SLAVESELECT,HIGH);


Quote
I forgot to comment in the code the last write, but in fact, the last one, is a writing to light up two leds:


oh, i c  8-)

the max chip is still not showing anything on my display... maybe i should also get an evkit board for trying out the code ... they seem to be not really easy available. you can buy them only directly through maxim, isn't it?

i was cleaning up your code a bit and put send/read functions for better overview.. could you try it out on your arduino? especially i am curious if the read functions are working!

Code: [Select]
#define DATAOUT 11      //MOSI
#define DATAIN  12      //MISO
#define SPICLOCK  13    //SCK
#define SLAVESELECT 10  //SS
#define RESET 9         //Reset

byte clr;

void spi_transfer(volatile char data)
{
 SPDR = data;                    // Start the transmission
 while (!(SPSR&_BV(SPIF))) { }
}

uint8_t spi_receive() {
 uint8_t val = 0;
 SPDR = 0x00; // Start clock
 while (!(SPSR&_BV(SPIF))) { }
   val = SPDR;
 return val;
}

void write8(uint8_t payload) {
 digitalWrite(SLAVESELECT,LOW);
 spi_transfer(payload);
 digitalWrite(SLAVESELECT,HIGH);
}

void write16(uint16_t payload) {
 payload &= 0xEFFF; // zero out the factory reserved bit / datasheet page 11
 digitalWrite(SLAVESELECT,LOW);
 spi_transfer(payload>>8);
 spi_transfer(payload&0xff);
 digitalWrite(SLAVESELECT,HIGH);
}

void write24(uint32_t payload) {
 payload &= 0xEFFF; // zero out the factory reserved bit / datasheet page 11
 digitalWrite(SLAVESELECT,LOW);
 spi_transfer(payload>>16);
 spi_transfer(payload>>8);
 spi_transfer(payload&0xff);
 digitalWrite(SLAVESELECT,HIGH);
}

uint8_t read16(uint16_t payload) {
 write16(payload);
 return spi_receive();
}

uint8_t read24(uint32_t payload) {
 write24(payload);
 return spi_receive();
}

void setup()
{
 Serial.begin(9600);
 Serial.println("booting...");
 
 pinMode(DATAOUT, OUTPUT);
 pinMode(DATAIN, INPUT);
 pinMode(SPICLOCK,OUTPUT);
 pinMode(SLAVESELECT,OUTPUT);
 pinMode(RESET,OUTPUT);

 // SPCR register
 // SPIE SPE DORD MSTR CPOL CPHA SPR1 SPR0
 //  D7  D6  D5   D4   D3    D2   D1   D0

 //interrupt disabled,spi enabled,msb 1st,master,clk low when idle,
 //sample on leading edge of clk,system clock/4 rate (fastest)
 SPCR = (1<<SPE)|(1<<MSTR);

 clr=SPSR;
 clr=SPDR;
 delay(10);

 digitalWrite(SLAVESELECT,HIGH);
 digitalWrite(RESET,HIGH);
 delay(5);
 digitalWrite(RESET,LOW);
 delay(5);
 digitalWrite(RESET,HIGH);
 delay(200);

 //Panel Configuration Register
 write16(0x0d01);

 //Panel Intensity Register
 write16(0x0230);

 //Number of Cascaded Devices Register
 write16(0x0e03);

 //Number of Display Rows Register
 write16(0x0f01);
 
 delay (500);

 //light up two leds, the first and the fifth, of the first row of the matrix
 write24(0x000088);
}

void loop()
{
while (1);
 {
 };

}



THUMBS UP ++ BIG THANKS for sharing your code  :)
ritzdank

Go Up