Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

MAX 7219 inerfacing with PHILIPS 8051 Software issue SPI PROTOCOL

Status
Not open for further replies.

sayonee

Newbie level 6
Joined
Nov 22, 2011
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,390
16122011(001).jpgHello there I am trying to implement SPI protocol.I am interfacing 7 segment circuit ( 4 units ) using MAX 7219 and I am not able to get the desired LED output ...please let me know where I am going wrong ...

Thanks

Code:
#include<reg51.h> 
#define uchar unsigned char
#define uint unsigned int
 
#define  HIGH     1
#define  LOW      0
#define  TRUE      1
#define  FALSE      0
#define  ZERO      0 
#define  MSB       0x80
#define  LSB       0x01
//max7219 part
#define  DECODE_MODE   0x09 
#define  INTENSITY     0x0A 
#define  SCAN_LIMIT    0x0B 
#define  SHUT_DOWN     0x0C 
#define  DISPLAY_TEST  0x0F 

//pin defined
/***********************************************************************/
//change this part at different board
sbit LOAD=P1^2; //MAX7219    Load-Data Input:    rising edge  pin 12 
sbit DIN=P1^1; //MAX7219    Serial-Data Input:   rising edge  pin 1
sbit CLK=P1^0; //MAX7219   Serial-Clock Input:  maximum 10MHz  pin 13


/***********************************************************************/
void Write_Max7219_byte(unsigned char temp);//write max7219 a byte
void Write_Max7219(unsigned char address,unsigned char dat);//write max7219 command and data
void Init_Max7219(void);//Initize max7219
void delay1ms(uint x);

/***********************************************************************/
void main(void)
{
 uchar i,j=1; 
 Init_Max7219();
 /*for(i=1;i<=4;i++)
 Write_Max7219(i,0); */
 for(i=0;i<=3;i++)
 Write_Max7219(i,0);
 while(TRUE)
 {
   
  for(i=1;i<9;i++) 
  {
   Write_Max7219(j,i);
   delay1ms(1000);
  }
  j++;
  if(j==5)
  {
  j=1;
  for(i=1;i<=4;i++)
  Write_Max7219(i,0);
  }
 } 
}
/***********************************************************************/
void Write_Max7219_byte(uchar temp)
{
 unsigned char i;
 for (i=0;i<8;i++)     
  { 
     CLK=LOW;
     DIN=(bit)(temp&MSB);      
     temp<<=1;
	 CLK=HIGH;
   }
}
/***********************************************************************/
void Write_Max7219(uchar address,uchar dat)
{ 
   LOAD=LOW;
   Write_Max7219_byte(address); 
   Write_Max7219_byte(dat);
   LOAD=HIGH;                 
}
/***********************************************************************/
void Init_Max7219(void)      
{ 
 Write_Max7219(SHUT_DOWN, 0x01);   //Normal Operation XXXXXXX1 Shutdown Mode   XXXXXXXX0
 Write_Max7219(DISPLAY_TEST, 0x00);   //Normal Operation XXXXXXX0 Display Test Mode XXXXXXXX1
 Write_Max7219(DECODE_MODE, 0xff);   //Decode Mode Select D7~D0 1 B decode 0 No decode 
 Write_Max7219(SCAN_LIMIT, 0x03);   //SCAN LIMIT 0~7 0xX0~0xX7
 Write_Max7219(INTENSITY, 0x04);   //Set Intensity   0xX0~0xXf
}

void delay1ms(uint x)
{
  uint i,j;
  for(i=0;i<x;i++)
    for(j=0;j<120;j++);
}
 
Last edited:

Hey,

Were you able to get it working.. If so let me know what correction you had to make.

Thanks
 

Hey,

Were you able to get it working.. If so let me know what correction you had to make.

Thanks


Hello djagadish

I was unsuccessful could be a hardware fault ..or something ..if you are able to get it working please let me know

thanks
 

Hi Sayonee,

I was able to get it working! One change is DIN=(bit)(temp&MSB); should be DIN=(temp & MSB == MSB ? 1:0);
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top