MAX7219 problem

I've bought 4 of these 8*8 led matrix modules, which use the MAX7219 chip.

I tested them by setting the display test register (0x0f) to 1. Which should light up all the leds at full brightness.

#include<SPI.h>

void setup() {
  SPI.begin();
  SPI.beginTransaction(SPISettings(10000000, MSBFIRST, SPI_MODE0));
  digitalWrite(2, LOW);
  SPI.transfer((byte)0x0f);
  SPI.transfer((byte)0x01);
  digitalWrite(2, HIGH);
  SPI.endTransaction();
}

But the display was missing some rows and columns. So i tried rotating it 180 degress but that way it didn't ligth up at all, except on one module where it lit up fully.

The led matricies which came are row cathode and column anode.

What have you done with chip select (CS) line?

The LED matrix must be fitted on the correct side of the PCB and the right way around. The module you have that has shown all LEDs on if the one that is correctly built.

Use a library that initializes the MAX7219 before trying to set any LEDs, the Arduino lines flap up and down for a while at power up and this can set the display chip into an unwanted state.

Test one module at a (time rather than 4 in a string) to check all the solder joints and connections are good.

If that get's you no closer to a working setup say how you have connected it and what library you are using, also post pictures of your setup.

CS is connected to pin 2, all other are connected to the ICSP header.

Garbage data shoudn't be a problem since the display test mode overrides all settings.

I tried the ledControl library, which seems to work fine. But i need more low level access to the chip.
I think i got the spi settings correctly, MSB first, clk idle when low, data is shifted in with rising edge.

Pin 2 is an odd choice for CLK.

So, to be clear, you have it running fine with the ledControl library and everything works but your own code?

What low level access features do you need?

Oops, meant to say CS. (edited)

Mostly for speed. Because LedControl does't adress multiple chips at once, it gets polynomially slower as you add more chips. And it's using software SPI.

You could try my MD_MAX72xx library (link in the signature block). I wrote it because I was fed up with the slowness of LedControl.

I experimented a bit and it turns out i forgot to set pin 2 to output.