what can I do MAX7219 cascade connection. I connectiong but data stored first MAX7219, others not working.
Code please. May be Proteus project at MicroC wroted.
Thank you ver much for your interesting.
SPI communication with MAX7219's cascade connection
Re: SPI communication with MAX7219's cascade connection
I have this same problem right now. And no one answered to you post! Did you manage some how to solve the problem? If yes, help me please!
-
- Posts: 2
- Joined: 09 Nov 2012 09:26
Re: SPI communication with MAX7219's cascade connection
When Cascading MAX7219's according to the Datasheet use the No-Op register.
if, for example, you have 3 MAX7219 Chips in cascade and you want to send a command to the third chip: here is what you do:
1. Connect all devices’ LOAD/CS inputs together and connect DOUT to DIN on adjacent devices.
2. send the desired 16-bit word, followed by two 16-bit no-op codes (2 pairs of zeros i.e. 0x00)
3. When LOAD/CS goes high, data is latched in all devices. The first 2 chips receive no-op commands, and the third receives the intended data.
I've included working code. i will attach an image as soon as I KNOW HOW to do so
NB: Remember to INITIALIZE all the MAX7219 Chips!!
Here is an Example code that works:
if, for example, you have 3 MAX7219 Chips in cascade and you want to send a command to the third chip: here is what you do:
1. Connect all devices’ LOAD/CS inputs together and connect DOUT to DIN on adjacent devices.
2. send the desired 16-bit word, followed by two 16-bit no-op codes (2 pairs of zeros i.e. 0x00)
3. When LOAD/CS goes high, data is latched in all devices. The first 2 chips receive no-op commands, and the third receives the intended data.
I've included working code. i will attach an image as soon as I KNOW HOW to do so
NB: Remember to INITIALIZE all the MAX7219 Chips!!
Here is an Example code that works:
Code: Select all
/****************************************************************************
*Currency Display System for Banks
*MikroC code
*this program shows how to use 3 MAX7219 Chips to Drive 3 8x7 Segment Displays
*****************************************************************************/
int j, dig;
//arrays for content to be displayed. this makes the program flexible!!
int Rands[8] = {0x80,8,5,0x0A,1,0x82,8,2}; //displays 0.85 and 12.82
int Pounds[8] = {0x81,2,5,0x0A, 0x0F, 0x80,9,3}; // displays 1.25 and 0.93
int Pula[8] = {0x87,7,4,0x0A,0x0F,0x80,6,5} ; //displays 7.74 and 0.65
//0x0A is a dash
// Serial 7-seg Display connections
sbit Chip_Select at RC0_bit;
sbit Chip_Select_Direction at TRISC0_bit;
// End Serial 7-seg Display connections
/*******Initialising MAXes*****************/
//initialise 1st MAX7219
void max7219_init1() {
Chip_Select = 0; // SELECT MAX
SPI1_write(0x09); // BCD mode for digit decoding
SPI1_write(0xFF); // using Code-B
Chip_Select = 1; // DESELECT MAX
Chip_Select = 0; // SELECT MAX
SPI1_write(0x0A);
SPI1_write(0x0F); // Segment luminosity intensity
Chip_Select = 1; // DESELECT MAX
Chip_Select = 0; // SELECT MAX
SPI1_write(0x0B);
SPI1_write(0x07); // Display refresh
Chip_Select = 1; // DESELECT MAX
Chip_Select = 0; // SELECT MAX
SPI1_write(0x0C);
SPI1_write(0x01); // Turn on the display
Chip_Select = 1; // DESELECT MAX
Chip_Select = 0; // SELECT MAX
SPI1_write(0x00);
SPI1_write(0xFF); // No test
Chip_Select = 1; // DESELECT MAX
}
//initialise 2nd chip
void max7219_init2() {
Chip_Select = 0; // SELECT MAX
SPI1_write(0x09); // BCD mode for digit decoding
SPI1_write(0xFF); // using Code-B
SPI1_write(0x00); // Bypass the 1st Chip
SPI1_write(0x00);
Chip_Select = 1; // DESELECT MAX
Chip_Select = 0; // SELECT MAX
SPI1_write(0x0A);
SPI1_write(0x0F); // Segment luminosity intensity
SPI1_write(0x00); // Bypass the 1st Chip
SPI1_write(0x00);
Chip_Select = 1; // DESELECT MAX
Chip_Select = 0; // SELECT MAX
SPI1_write(0x0B);
SPI1_write(0x07); // Display refresh
SPI1_write(0x00); // Bypass the 1st Chip
SPI1_write(0x00);
Chip_Select = 1; // DESELECT MAX
Chip_Select = 0; // SELECT MAX
SPI1_write(0x0C);
SPI1_write(0x01); // Turn on the display
SPI1_write(0x00); // Bypass the 1st Chip
SPI1_write(0x00);
Chip_Select = 1; // DESELECT MAX
Chip_Select = 0; // SELECT MAX
SPI1_write(0x00);
SPI1_write(0xFF); // No test
SPI1_write(0x00); // Bypass the 1st Chip
SPI1_write(0x00);
Chip_Select = 1; // DESELECT MAX
}
//initialise third chip
void max7219_init3() {
Chip_Select = 0; // SELECT MAX
SPI1_write(0x09); // BCD mode for digit decoding
SPI1_write(0xFF); // using Code-B
SPI1_write(0x00); // Bypass the First Chip
SPI1_write(0x00);
SPI1_write(0x00); // Bypass the Second Chip
SPI1_write(0x00);
Chip_Select = 1; // DESELECT MAX
Chip_Select = 0; // SELECT MAX
SPI1_write(0x0A);
SPI1_write(0x0F); // Segment luminosity intensity
SPI1_write(0x00); // Bypass the 1st Chip
SPI1_write(0x00);
SPI1_write(0x00); // Bypass the 2nd Chip
SPI1_write(0x00);
Chip_Select = 1; // DESELECT MAX
Chip_Select = 0; // SELECT MAX
SPI1_write(0x0B);
SPI1_write(0x07); // Display refresh
SPI1_write(0x00); // Bypass the 1st Chip
SPI1_write(0x00);
SPI1_write(0x00); // Bypass the 2nd Chip
SPI1_write(0x00);
Chip_Select = 1; // DESELECT MAX
Chip_Select = 0; // SELECT MAX
SPI1_write(0x0C);
SPI1_write(0x01); // Turn on the display
SPI1_write(0x00); // Bypass the 1st Chip
SPI1_write(0x00);
SPI1_write(0x00); // Bypass the 2nd Chip
SPI1_write(0x00);
Chip_Select = 1; // DESELECT MAX
Chip_Select = 0; // SELECT MAX
SPI1_write(0x00);
SPI1_write(0xFF); // No test
SPI1_write(0x00); // Bypass the 1st Chip
SPI1_write(0x00);
SPI1_write(0x00); // Bypass the 2nd Chip
SPI1_write(0x00);
Chip_Select = 1; // DESELECT MAX
}
/**********End of MAX7219 Initialisation**********/
void main() {
Chip_Select_Direction = 0; // Set RC0 pin as output
SPI1_init(); // Initialize SPI1 module
max7219_init1(); // initialize 1st max7219
max7219_init2(); // initialize 2nd max7219
max7219_init3(); // initialize 3rd max7219
// while(1){
// Auto Incrementing code for the int array***
//1st Chip:
dig = 0;
for (j=1; j<9; j++) {
Chip_Select = 0; // select max7219
SPI1_write(j); // send j to max7219 (digit place)
SPI1_write(Rands[dig]);
Chip_Select = 1; // deselect max7219
dig++;
}
//Auto Inc. Ends Here /
// Auto Incrementing code for the int array***
//2nd Chip:
dig = 0;
for (j=1; j<9; j++) {
Chip_Select = 0; // select max7219
SPI1_write(j); // send j to max7219 (digit place)
SPI1_write(Pounds[dig]);
SPI1_Write(0x00);
SPI1_Write(0x00); //Bypass 1st chip...
Chip_Select = 1; // deselect max7219
dig++;
}
//Auto Inc. Ends Here /
// Auto Incrementing code for the int array***
//3rd Chip:
dig = 0;
for (j=1; j<9; j++) {
Chip_Select = 0; // select max7219
SPI1_write(j); // send j to max7219 (digit place)
SPI1_write(Pula[dig]);
SPI1_Write(0x00); //Bypass 1st Chip
SPI1_Write(0x00);
SPI1_Write(0x00); //Bypass 2nd Chip
SPI1_Write(0x00);
Chip_Select = 1; // deselect max7219
dig++;
}
//Auto Inc. Ends Here /
// }
}
-
- Posts: 2
- Joined: 09 Nov 2012 09:26
Re: SPI communication with MAX7219's cascade connection
Before I forget, Special Thanks to ducu for the initial MAX7219 code.