I'm trying to figure out if there is some fundamental reason this won't work. One of my concerns is weather I2C to the mcp23017 is fast enough to control the max7219. If not would the mcp23s17 potentially be viable.
Thoughts?
I'm trying to figure out if there is some fundamental reason this won't work. One of my concerns is weather I2C to the mcp23017 is fast enough to control the max7219. If not would the mcp23s17 potentially be viable.
Thoughts?
MAX7219 needs signals that are SPI based, not I2C. It does not provide any feedback, such as the ACK bit that I2C needs back from slave to master.
digitalWrite (csPin, LOW);
SPI.transfer(registerAddress);
SPI.transfer(data);
digitalWrite (csPin, HIGH);
Can run them at 4 MHz clock no problem (default SPI clock speed). I've not tried running them ridiculously slow, like 100KHz or 400KHz I2C clock speeds.
Hi, in the past I have "bit-banged" max7219 with Picaxe MCUs (interpreted BASIC) which is really, really slow. So a slow speed is unlikely to be the problem, assuming you are trying to bit-bang with the mcp's outputs.
Paul
The MAX7219 does not care a hoot about how fast - or slow - you address it; it is properly buffered internally and standard "static" CMOS logic. If you provide de-bouncing, you could set it up using toggle switches!
You do introduce additional complexity and slow it by an order of magnitude or two by introducing indirection in the protocol, but even then it is performing at microprocessor speed and updating far too fast to be visually discernible.
ok, good to know bit banging is an option
So a little background on this, I have run out of pins on my arduino.
I am using the max7219 for my display output
I am also using the w5100 standard Ethernet shield.
I have been told they are both spi based devices so shouldn't I be able to reuse the SPI at the expense of a single pin for CS?
cgriffin:
shouldn't I be able to reuse the SPI at the expense of a single pin for CS?
According to this page pin 10 is the CS for the Ethernet chip and pin 4 is CS for the SD card. So I think if you can find a free pin for your max7219 CS, you can hook it up to the spi bus too.
That is great news! However I am currently unable to get it to work. I was told of a mod that was required for the spi to be released by the ethernet shield but I am unaware if that affects the newer shields.
I think ethernet only hangs on the MISO line, which you will not be connecting to the MAX7219, so not a problem.
If it is, you can buffer the MISO from the ethernet with a HC125 buffer (part of a quad buffer package, or use one of the SMD single gate versions) with the ethernet CS controlling the '125 OE so ethernet MISO is fully isolated.
It appears the ethernet will not give up one line or another. The max7219 initialized fine (before the ethernet init) but nothing gets output to the max7219 after the ethernet.begin. However if I comment out ethernet.begin() the max works fine. The Ethernet always works once initialized.
Any thoughts on this issue would be greatly appreciated.
#include <SPI.h>
#include <Ethernet.h>
#include <LedControl.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
#define MOSI_PIN 11 // MOSI
#define MISO_PIN 12 // MISO
#define SCK_PIN 13 // sck
#define ETH_SS 10 // ss
#define MAX_SS 7 // ss
IPAddress ip(192,168,1,177);
/*
Now we need a LedControl to work with.
***** These pin numbers will probably not work with your hardware *****
pin 12 is connected to the DataIn
pin 11 is connected to the CLK
pin 10 is connected to LOAD
We have only a single MAX72XX.
*/
LedControl mydisplay=LedControl(MOSI,SCK,MAX_SS,1);
void setup()
{
Serial.begin(115200); // start serial port
pinMode(MAX_SS,OUTPUT);
pinMode(ETH_SS, OUTPUT);
digitalWrite(MAX_SS,HIGH);
digitalWrite(ETH_SS,HIGH);
mydisplay.shutdown(0,false);
/* Set the brightness to a medium values */
mydisplay.setIntensity(0,8);
mydisplay.shutdown(0, false); // turns on display
mydisplay.setIntensity(0, 8); // 15 = brightest
mydisplay.setDigit(0, 0, 9, false);
mydisplay.setDigit(0, 1, 8, false);
mydisplay.setDigit(0, 2, 7, false);
mydisplay.setDigit(0, 3, 6, false);
mydisplay.setDigit(0, 4, 5, true);
mydisplay.setDigit(0, 5, 4, false);
mydisplay.setDigit(0, 6, 3, false);
mydisplay.setDigit(0, 7, 2, false);
delay(3000);
/* and clear the display */
mydisplay.clearDisplay(0);
Serial.println("display initialized");
Ethernet.begin(mac, ip);
Serial.println("ethernet initialized");
delay(2000);
digitalWrite(ETH_SS,HIGH);
}
void loop()
{
digitalWrite(ETH_SS,HIGH);
digitalWrite(MAX_SS,LOW);
mydisplay.setDigit(0, 0, 1, false);
mydisplay.setDigit(0, 1, 1, false);
mydisplay.setDigit(0, 2, 1, false);
mydisplay.setDigit(0, 3, 1, false);
digitalWrite(MAX_SS,HIGH);
digitalWrite(ETH_SS,LOW);
/* add main program code here */
}