Go Down

Topic: Bug in MAX7219 LED driver example code (Read 1 time) previous topic - next topic


Hello, the code in the built-in example file (examples/leds/led_drivers/max7219_v1) and the playground file http://www.arduino.cc/playground/LEDMatrix/Max7219 have bugs in them.  As it so happens, the code will still work with a 7219 but not with an identical, fully SPI-compatible chip like the 7221.  

In the max7219_put function, the load line should be set LOW to begin, not HIGH.  this is not strictly necessary for the 7219, only the 7221.  But it is technically wrong regardless.  ["For the MAX7219, serial data ... is shifted ... with each rising edge of CLK regardless of the state of LOAD. For the MAX7221, CS [LOAD] must be low to clock data in or out."]  

Code: [Select]
void max7219_put(byte reg, byte data)
 max7219_setLoad(LOW);  // begin    ** in the example this is HIGH, which is wrong! **
 max7219_putByte(reg);  // specify register
 max7219_putByte(data); // put data
 max7219_setLoad(LOW);  // latch in data
 max7219_setLoad(HIGH); // end

Go Up