swapan
Full Member level 4
Hi
After going through some tutorial on driving 8x8 LED matrix by MAX7219, I am trying to undertake simple practical tests. I have bought 4 cascaded 8x8 LED matrix assembled with MAX7219. The arrangement of the setup is as per attached schematic. As a simple test I want to activate only one column of the matrix. Please see the code also. On powering up, the circuit shows weird behavior. Sometimes all the columns are on, sometimes a portion is on, sometimes the entire matrix is off. This is the first time I am working on MAX7219 and SPI module. Please help me to sort out the problem.
View attachment untitled.pdf
After going through some tutorial on driving 8x8 LED matrix by MAX7219, I am trying to undertake simple practical tests. I have bought 4 cascaded 8x8 LED matrix assembled with MAX7219. The arrangement of the setup is as per attached schematic. As a simple test I want to activate only one column of the matrix. Please see the code also. On powering up, the circuit shows weird behavior. Sometimes all the columns are on, sometimes a portion is on, sometimes the entire matrix is off. This is the first time I am working on MAX7219 and SPI module. Please help me to sort out the problem.
Code:
sbit Chip_Select at RC4_bit;
sbit Chip_Select_Direction at TRISC4_bit;
void max7219_init1() {
Chip_Select = 0; // SELECT MAX
SPI1_write(0x09); // BCD mode for digit decoding
SPI1_write(0x00);
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
}
void main() {
Chip_Select_Direction = 0; // Set RC0 pin as output
SPI1_init(); // Initialize SPI1 module
max7219_init1(); // initialize max7219
Chip_Select = 0; // select max7219
SPI1_write(1); // send i to max7219 (digit place)
SPI1_write(0xFF);
Chip_Select = 1; // deselect max7219
while(1);
}