SPI and MAX7219

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times

SPI and MAX7219

Post by jgu1 »

Hi all!

I bought one of these modules : http://www.ebay.com/itm/390617477277?ss ... 1497.l2649 I have tried and tried with various examples from MM and my own. I actually thought it was easy, but it is not. After trying, I must admit., it's hard. :(
No matter what I do is either light in all segments or nothing happend or all the led flicker.
I understand that it is possible to send data and receive data. via SPI.
I can not find anything on the topic in the help.
When I look in the properties of SPI, I can see there are various options which I do not understand. At the same time the names of the legs in the config for Pic is not the same as the MAX7219

I have previously been promised by Enamul an example, but did not we hear much of him more in this forum?

Is there anyone here who will help with a small example that could write 1 2 3 4 5 6 7 in the display, and maybe a little drawing with the pins from Pic to modul. Maybe with a with a 16F876 or 16F88 so it´s possible so I could find the "ligth."

I would really be grateful now that I have tried a lot and now it irritates me that I can not figure it out

Thank´s in advance

Jorgen

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times

Re: SPI and MAX7219

Post by dazz »

HI
The pins are
Pic Connect to Max
SDO DIN
SCK CLK
SS LOAD/CS
The dout pin on the max is for connecting another display
Not played with spi much, but the data that needs to be sent is in the datasheet

Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times

Re: SPI and MAX7219

Post by jgu1 »

Hej Dazz!

Thank´s for your help. :D
as you describe, it is the way I have done. But unfortunately it does not work. I still need to know how the configuration should be. and how to write for different digits. And what kind of data I have to use in the componentmacro.
When I look with my scoop comes pulses out on some of the outputs.
I can imagine SPI is a system which sends clock data signal and latch. something similar to the shift register. (74HC595.) SPI is able to send and receive.
I wish to learn and understand SPI.
I have attached one of my attempts.

Hope sombody can help. :lol:

Best regard

Jorgen
Attachments
SpiTest.fcf
(8.5 KiB) Downloaded 306 times

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times

Re: SPI and MAX7219

Post by dazz »

Hi Jorgen
im not good with spi but will have a quick look and see if ican help but it will be later today, will sent this thread to someone and hopethey can pop in and have a look

Regards
DAzz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times

Re: SPI and MAX7219

Post by kersing »

Hi Jorgen,

What pin did you connect to the LOAD/CS pin to?

Because you are using the 'low-level' SPI commands, you need to drive the LOAD/CS pin yourself. The initialization sequence for SPI would be:
Set LOAD/CS pin to HIGH (Output Icon, set pin to 1)
Initialize SPI (SPI_Init)

If you look at the data sheet for the 7219, page 6 lists the data format used. For each digit you want to display you need to provide two bytes, one is the address, the second the data to display.
The table on page 7 lists the addresses for the individual digits. The first (digit 0) is 0xX1, the last (digit 7) 0xX8. As the X may be anything the easiest way is to address them as 0x01 - 0x08. What data to send depends on the mode the display is set to. In the default setting you are able to address every segment by setting a bit as shown in table 6.

To display the number 1 on the first digit and nothing on the others.

Code: Select all

Set LOAD/CS pin to LOW (Output Icon, set pin to 0)  : This addresses the display
SPI_Send_Char(0x0B) : Send command to set 'scan' digits
SPI_Send_Char(0x07) : table 8 - All digits active
SPI_Send_Char(0x01) : Command to address first digit
SPI_Send_Char(0x30) : segments B & C on (table 5)
SPI_Send_Char(0x02) : Command to address second digit
SPI_Send_Char(0x00) : no segments on (replace with 0x6D for 2)
SPI_Send_Char(0x03) : Command to address third digit
SPI_Send_Char(0x00) : no segments on
SPI_Send_Char(0x04) : Command to address fourth digit
SPI_Send_Char(0x00) : no segments on
SPI_Send_Char(0x05) : Command to address fifth digit
SPI_Send_Char(0x00) : no segments on
SPI_Send_Char(0x06) : Command to address sixth digit
SPI_Send_Char(0x00) : no segments on
SPI_Send_Char(0x07) : Command to address seventh digit
SPI_Send_Char(0x00) : no segments on
SPI_Send_Char(0x08) : Command to address eighth digit
SPI_Send_Char(0x00) : no segments on
Set LOAD/CS pin to HIGH (Output Icon, set pin to 1)  : We're done using the display
Good luck!

Jac
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times

Re: SPI and MAX7219

Post by jgu1 »

Hi Jac!

Thank you for your explanation!

I think I have tried almost everything without success. But I will try to follow your explanation step by step.
But it's a little confusing for me when I look at the names on the pin for SPI. For nearly every data sheet, they have a new name. :roll:

I am completely inexperienced in SPI. the best thing for me would be an example of FC and a small diagram with pin connection, so I had the opportunity to study the program and look at signals with a scoop.

I continue with your explanation, now there's a little more to get on with, thanks again to both of you. :D

Best regard

Jorgen

Post Reply