Page 1 of 1

Making max7219 LED matrix display work over SPI

Posted: Fri Sep 26, 2014 8:12 pm
by riklaunim
I'm trying to port pyMCU code (https://github.com/riklaunim/max7219/bl ... ay_text.py) for max7219 LED matrix - http://www.dx.com/p/max7219-dot-matrix- ... nes-184854

It uses SPI, and for pyMCU init looks like so:

Code: Select all

#clockPolarity, clockFreq, clockSelect, clockSample
mb.spiEnable(1, 1000, 0, 0)
The send_byte function that sends everything via SPI looks like so:

Code: Select all

def send_byte(register, data):
mb.pinLow(4)
mb.spiTransfer([register, data])
mb.pinHigh(4)
Pin 4 is MISO and it's down for send, up for execute as that how that max7219 works.


For pyboard I used:

Code: Select all

spi = pyb.SPI(1, pyb.SPI.MASTER, baudrate=1000, polarity=1, phase=1)
and the function:

Code: Select all

def send_byte(register, data):
    global spi
    to_send = b'%s%s' % (register, data)
    pyb.Pin('X7', pyb.Pin.IN).low()
    spi.send(to_send)
    pyb.Pin('X7', pyb.Pin.IN).high()
But still something is wrong as I only get "random" blinking on the LED matrix. I assume it's either the SPI init or data format that is the problem.

DIN - X8
CS - X7
CLK - X6