Making max7219 LED matrix display work over SPI

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
riklaunim
Posts: 32
Joined: Fri Aug 22, 2014 5:42 pm

Making max7219 LED matrix display work over SPI

Post by riklaunim » Fri Sep 26, 2014 8:12 pm

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

Post Reply