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.

MAX7219 turn into working

Status
Not open for further replies.

imranahmed

Advanced Member level 3
Advanced Member level 3
Joined
Dec 4, 2011
Messages
822
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
Karachi,Pakistan
Visit site
Activity points
6,533
Please let me know that I am interface MAX7219 with Arduino UNO and connect necessary

connection on breadboard and using common cathode 3-digit 7-segment display.

But when turn it on all digits are lit up and no data is display.

And I am using library "LedControlMS"
 

All digits are on in test mode. You should perform initialization first.
Code:
#include "MAX7219.h"

#define MAX7219_SPI								SPI1		//interface definition
#define MAX7219_MaxCountValue			12			//maximum vaule of chips in serial to scan

/* You can manualy assign the value of chips in serialy connected here*/
unsigned char ChipsInSerial=0;	//otherwise search procedure will be needed and loop must be closed

unsigned char DigitsPerChip=8;

unsigned char MAX7219_WriteReg (unsigned char Reg, unsigned char Data);

unsigned char MAX7219_WriteReg (unsigned char Reg, unsigned char Data)
{
	unsigned char cnt=0;
	unsigned char tmp=0;
	
	if (ChipsInSerial==0) 
	{
		PIN_OFF(CS);
		for (tmp=0;tmp!=MAX7219_MaxCountValue;tmp++) SPI_SendByte(MAX7219_SPI, MAX7219_NoOperation);
		PIN_ON(CS);
		PIN_OFF(CS);
		tmp=0;
		while ((tmp!=Reg)&(cnt<MAX7219_MaxCountValue)) 
		{	
			tmp=SPI_ReadByte(MAX7219_SPI, Reg);
			SPI_SendByte(MAX7219_SPI, Data);
			cnt++;
		}
		PIN_ON(CS);
		ChipsInSerial = cnt-1;
	}
	else
	{
		PIN_OFF(CS);
		for (tmp=0;tmp!=ChipsInSerial;tmp++)
		{
			SPI_SendByte(MAX7219_SPI, Reg);
			SPI_SendByte(MAX7219_SPI, Data);
		}
		PIN_ON(CS);
	}
	return ChipsInSerial;
}

unsigned char MAX7219_Init (MAX7219Init_TypeDef * MAX7219_InitStruct)
{
	MAX7219_DisplayTestVoid(0);
	DigitsPerChip = MAX7219_InitStruct->ScanLimit+1;
	MAX7219_WriteReg(MAX7219_DecodeMode, MAX7219_InitStruct->DecodeMode);
	MAX7219_WriteReg(MAX7219_Intensity, MAX7219_InitStruct->Intensity);
	MAX7219_WriteReg(MAX7219_ScanLimit, MAX7219_InitStruct->ScanLimit);
	return MAX7219_WriteReg(MAX7219_ShutDown, MAX7219_InitStruct->ShutDown);
}

void MAX7219_StructInit (MAX7219Init_TypeDef * MAX7219_InitStruct, unsigned char DigitsPerChip)
{
	MAX7219_InitStruct->DecodeMode=0xFF;	//code B 0..7
	MAX7219_InitStruct->Intensity=8;	//0...16
	MAX7219_InitStruct->ScanLimit=(DigitsPerChip-1);
	MAX7219_InitStruct->ShutDown=1;
}

void MAX7219_DrawDigitSerial (unsigned char * Digit)
{
	unsigned char ChipCNT;
	unsigned char DigitCNT = DigitsPerChip;

	for (DigitCNT=0;  DigitCNT!=DigitsPerChip; DigitCNT++)
	{
		PIN_OFF(CS);
		for (ChipCNT=0; ChipCNT!=ChipsInSerial; ChipCNT++)
		{
				SPI_SendByte(MAX7219_SPI, (DigitCNT+1));
				SPI_SendByte(MAX7219_SPI, Digit[(ChipsInSerial-ChipCNT-1)*DigitsPerChip+DigitCNT]);			
		}
		PIN_ON(CS);
	}
}

void MAX7219_DisplayTestVoid (unsigned char Enable)
{
	MAX7219_WriteReg(MAX7219_DisplayTest, Enable);
}

void MAX7219_SetIntensity (unsigned char Intensity)
{
	MAX7219_WriteReg(MAX7219_Intensity, Intensity&0x0F);
}

void MAX7219_Power (unsigned char PowerState)
{
	MAX7219_WriteReg(MAX7219_ShutDown, PowerState);
}

void MAX7219_DrawCharSerial (unsigned char CHAR, const unsigned long (*FONT)[])
{
	unsigned char DigitArray[8];
	CHAR=CHAR<<1;
	DigitArray[0]=((*FONT)[CHAR]&0xFF000000)>>24;
	DigitArray[1]=((*FONT)[CHAR]&0x00FF0000)>>16;
	DigitArray[2]=((*FONT)[CHAR]&0x0000FF00)>>8;
	DigitArray[3]=((*FONT)[CHAR]&0x000000FF);
	DigitArray[4]=((*FONT+1)[CHAR]&0xFF000000)>>24;
	DigitArray[5]=((*FONT+1)[CHAR]&0x00FF0000)>>16;
	DigitArray[6]=((*FONT+1)[CHAR]&0x0000FF00)>>8;
	DigitArray[7]=((*FONT+1)[CHAR]&0x000000FF);
	MAX7219_DrawDigitSerial(DigitArray);
}
Code:
#include "spi.h"
#include "stm32_GPIO.h"

#define CS														GPIOA, GPIO_Pin_2

#define MAX7219_NoOperation						0xA0
#define MAX7219_DecodeMode						0xA9
#define MAX7219_Intensity							0xAA
#define MAX7219_ScanLimit							0xAB
#define MAX7219_ShutDown							0xAC
#define MAX7219_DisplayTest						0xAF


typedef struct
{
	unsigned char DecodeMode;
	unsigned char Intensity;
	unsigned char ScanLimit;
	unsigned char ShutDown;
}MAX7219Init_TypeDef;

unsigned char MAX7219_Init (MAX7219Init_TypeDef * MAX7219_InitStruct);
void MAX7219_StructInit (MAX7219Init_TypeDef * MAX7219_InitStruct, unsigned char DigitsPerChip);
void MAX7219_DrawDigitSerial (unsigned char * Digit);
void MAX7219_DisplayTestVoid (unsigned char Enable);
void MAX7219_SetIntensity (unsigned char Intensity);
void MAX7219_Power (unsigned char PowerState);
void MAX7219_DrawCharSerial (unsigned char CHAR, const unsigned long (*FONT)[]);
 

All digits are on in test mode. You should perform initialization first.

Dear Easyrider83,

I performed initialization but no effect. Only proteus simulation is running the code successfully.
Code:
void setup()
{
   /*
   The MAX72XX is in power-saving mode on startup,
   we have to do a wakeup call
   */
   lc.shutdown(0,false);
 
   /* Set the brightness to a medium values */
   lc.setIntensity(0,15);

   /* and clear the display */
   lc.clearDisplay(0);
  
   
}

- - - Updated - - -

No dear milan.rajik,

I am using my own built circuit of 3-digit 7 segment display and also they are multiplexed.

Proteus simulation is running but in breadboard all segments are lit up fully.
 

Proteus simulation is running but in breadboard all segments are lit up fully.

check out the clock signal on the scope.make sure you have proper clock provided at your breadboard.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top