MAX7219 interface


The MAX7219 is a compact, serial input/output common-cathode display drivers that interface
microcontroller to 7-segment numeric LED displays of up to 8 digits, bar-graph displays, or 64 individual
LEDs. Included on-chip are a BCD code-B decoder, multiplex scan circuitry, segment and digit
drivers, and an 8x8 static RAM that stores each digit.


Only one external resistor is required to set the segment current for all LEDs. The MAX7221 is compatible
with SPI™, QSPI™, and MICROWIRE™, and has slewrate-limited segment drivers to reduce EMI.
A convenient 4-wire serial interface connects to all common ìPs. Individual digits may be addressed and
updated without rewriting the entire display. The MAX7219/MAX7221 also allow the user to select
code-B decoding or no-decode for each digit.

The devices include a 150mA low-power shutdown mode, analog and digital brightness control, a scanlimit
register that allows the user to display from 1 to 8 digits, and a test mode that forces all LEDs on.
The Basic initialisation program comes here

void max7219_init()
{
 
  PORTC = 0xFD;                         //ON MAX
  SPI_write(0x09);                     //BCD mode
  SPI_write(0xFF);        
  PORTC = 0x02;                        //OFF MAX

  PORTC = 0xFD;                        //ON MAX
  SPI_write(0x0A);                   //Intensity
  SPI_write(0x0F);
  PORTC = 0x02;                       //OFF MAX

  PORTC = 0xFD;                       //ON MAX
  SPI_write(0x0B);                   //Display refresh
  SPI_write(0x07);
  PORTC = 0x02;                       //OFF MAX

  PORTC = 0xFD;                       //ON MAX
  SPI_write(0x0C);                   //Turn on the display
  SPI_write(0x01);
  PORTC = 0x02;                      // OFF MAX

  PORTC = 0xFD;                       //ON MAX
  SPI_write(0x00);                   //NO Test
  SPI_write(0xFF);
  PORTC = 0x02;                       //OFF MAX

}
Sample Program


#include "m7219.c"

unsigned char i;

void main()
{

  delay_ms(100);
  SPI_init();             
  delay_ms(100);
                       
  TRISC &= 0xFD;
  delay_ms(100);
  max7219_init();         
 
  for (i = 1; i<=8; i++)
   {
       PORTC &= 0xFD;         
       SPI_write(i);
       SPI_write(8-i);        
       delay_ms(500);
       PORTC = 0x02;
   }

}
            
Any PIC with Hardware SPI will work.. Now you can use up to eight 7-segment displays in your project using MAX7219. Make changes according to your project needs. Go through with datasheet of MAX7219 to get all functions.



PCB for MAX7219 Display Driver
Downloads

Datasheet - Max7219

Pcb - (Eagle format)

Circuit