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.

Dot matrix Display @ scrolling problem

Status
Not open for further replies.

dhakeparag81

Full Member level 2
Full Member level 2
Joined
Jun 6, 2012
Messages
142
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Location
INDIA
Visit site
Activity points
2,469
hello there,

Last time i post about typecasting char array to store address in unsigned int.
Now my new problem is about same project. Due to facing difficulties about using pointer i converted my program little different way.

In my project i used 5x7 dot matrix displays, each row having 10 display and total rows are 6.
when i display 10 characters in each row at that time i didn't face a problem, but when i scrolling them that time only first and last(6) row working perfectly, in other rows at particular time some of displays getting blank.

I am trying to figure it out but didnt get result, hopping u will suggest me the correct way.

Code:
#include<p18f4520.h>
#include<delays.h>

#define CS1 LATCbits.LATC2  //Latching ic chip select
#define CS2 LATCbits.LATC1  //Latching ic chip select
#define CS3 LATCbits.LATC0  //Latching ic chip select
#define CS4 LATEbits.LATE2  //Latching ic chip select
#define CS5 LATEbits.LATE1  //Latching ic chip select
#define CS6 LATEbits.LATE0  //Latching ic chip select

#define CLK1 LATBbits.LATB5   //clock for shift register 74hc164
#define CLK2 LATBbits.LATB4   //clock for shift register 74hc164
#define CLK3 LATBbits.LATB3   //clock for shift register 74hc164
#define CLK4 LATBbits.LATB2   //clock for shift register 74hc164
#define CLK5 LATBbits.LATB1   //clock for shift register 74hc164
#define CLK6 LATBbits.LATB0   //clock for shift register 74hc164

#define SDATA1 LATCbits.LATC6   //Data for shift register
#define SDATA2 LATCbits.LATC7   //Data for shift register
#define SDATA3 LATDbits.LATD4   //Data for shift register
#define SDATA4 LATDbits.LATD5   //Data for shift register
#define SDATA5 LATDbits.LATD6   //Data for shift register
#define SDATA6 LATDbits.LATD7   //Data for shift register

#pragma idata name0

unsigned char str1[50]="J.T. MAHAJAN, C.O.E., FAIZPUR, DEPT. OF E&TC.   ";//46
unsigned char str2[60]="A.M. PATIL PROF. & H.O.D.  P.M. MAHAJAN ASSO. PROF.   ";//52
unsigned char str3[55]="S.V. PATIL  ASSO. PROF.  K.S. BHAGAT  ASSO. PROF.   ";//49

#pragma idata name7
unsigned char str4[73]="N.S. PATIL  ASS. PROF.  O.K. FIRKE ASS. PROF.  G.D. BONDE ASS. PROF.   ";//69
unsigned char str5[80]="R.D. CHAUDHARI ASS. PROF.  A.B. NEHETE ASS. PROF.  G.L. ATTERDE ASS. PROF.   ";//75
unsigned char str6[82]="S.R. PACHPANDE ASS. PROF.  Y.K. KIRANGE ASS. PROF.   R.C. BAKSHE ASS. PROF.  ";//75

#pragma idata name1

unsigned char alphabets[215]={0x04, 0x0A, 0x11, 0x11, 0x1F, 0x11, 0x11,		//A
							  0x0F, 0x11, 0x11, 0x0F, 0x11, 0x11, 0x0F,		//B
							  0x0E, 0x11, 0x01, 0x01, 0x01, 0x11, 0x0E,		//C
							  0x0F, 0x12, 0x12, 0x12, 0x12, 0x12, 0x0F,		//D
							  0x1F, 0x01, 0x01, 0x0F, 0x01, 0x01, 0x1F,		//E
							  0x1F, 0x01, 0x01, 0x07, 0x01, 0x01, 0x01,		//F
							  0x0E, 0x11, 0x01, 0x1D, 0x11, 0x11, 0x0E,		//G
							  0x11, 0x11, 0x11, 0x1F, 0x11, 0x11, 0x11,		//H
							  0x0E, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0E,		//I
							  0x1C, 0x08, 0x08, 0x08, 0x08, 0x09, 0x06,		//J
							  0x11, 0x09, 0x05, 0x03, 0x05, 0x09, 0x11,		//K
							  0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x1F,		//L
							  0x11, 0x1B, 0x15, 0x15, 0x11, 0x11, 0x11,		//M
							  0x11, 0x13, 0x15, 0x19, 0x11, 0x11, 0x11,		//N
							  0x0E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0E,		//O
							  0x0F, 0x11, 0x11, 0x0F, 0x01, 0x01, 0x01,		//P
							  0x0E, 0x11, 0x11, 0x11, 0x15, 0x09, 0x16,		//Q
							  0x0F, 0x11, 0x11, 0x0F, 0x05, 0x09, 0x11,		//R
							  0x0E, 0x11, 0x01, 0x0E, 0x10, 0x11, 0x0E,		//S
							  0x1F, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,		//T
							  0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0E,		//U
							  0x11, 0x11, 0x11, 0x0A, 0x0A, 0x04, 0x04,		//V
							  0x11, 0x11, 0x11, 0x15, 0x15, 0x1B, 0x11,		//W
							  0x11, 0x11, 0x0A, 0x04, 0x0A, 0x11, 0x11,		//X
							  0x11, 0x11, 0x0A, 0x04, 0x04, 0x04, 0x04,		//Y
							  0x1F, 0x10, 0x08, 0x04, 0x02, 0x01, 0x1F,		//Z
							  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,		//.
							  0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x02, 	//,
							  0x02, 0x05, 0x05, 0x02, 0x15, 0x09, 0x16,		//&
							  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};	//

#pragma idata name2
							  
unsigned char no_shift=0;
unsigned int k=0, j=0, i=0, jk=0, count=0,count2=0,count3=0,count4=0,count5=0,count6=0, shifting1=0,shifting2=0,shifting3=0,shifting4=0,shifting5=0,shifting6=0, temp1=0;
unsigned char shift_data=0;

#pragma udata name5
unsigned char first=0, second=0, third=0, fourth=0, fifth=0, sixth=0;//, *sixth_ptr=0;
unsigned char temp_no=0,*tmp=0;

#pragma udata name3
unsigned char temp_array[16]={0}; 

#pragma idata name4

void char_data_conv(unsigned char alpha);
void data_conversion(unsigned char data);
void nop(void);

unsigned char title_row(unsigned int num1);
unsigned char second_row(unsigned char num2);
unsigned char third_row(unsigned char num3);
unsigned char fourth_row(unsigned char num4);
unsigned char fifth_row(unsigned char num5);
unsigned char sixth_row(unsigned char num6);

#pragma code High_Vector_Section=0x08
void high_isr (void);

void High_Vector_Section (void)
{
	_asm goto high_isr _endasm
}

/***********************************************************************************************************************************************************************************************************/

#pragma code
#pragma interrupt high_isr

void high_isr()
{
	
	
	if(INTCONbits.TMR0IF == 1)							// Timer0 causes interrupt.....?
    {
	   										// Yes Then Execute Timer0 ISR.
	   INTCONbits.TMR0IF = 0;
	}

	
}


void main (void)
{

//	OSCTUNE		= 0x80;									//INTSRC = 1.		
//	OSCCON		= 0x76;									//IRCF2:IRCF0 = 1 i.e 8 MHz, I0FS = 1 Freq Is Stable, SCS1:SCS0 = 10 i.e Internal OSC Block.

	RCON		= 0xDF;									//IPEN = 1....
	INTCON		= 0xE0;									// GIE = 1, PEIE = 1, TMR0IE = 1.
	INTCON2		= 0x00;
	INTCON3		= 0x00;	
	
	T0CON		= 0x88;									//TMR0ON = 1, PSA = 1.
	TMR0H		= 0xB1;									//Timer0 Registers.
	TMR0L		= 0xDF;
	
	ADCON1		= 0x0F;									//A/D OFF, Configure As Digital I/O Pin.
	CMCON		= 0x07;							
		
	INTCONbits.INT0IF=0;
	INTCONbits.RBIF=0;
	
	

	TRISCbits.TRISC2=0;
	TRISCbits.TRISC5=0;
	TRISCbits.TRISC4=0;
	TRISCbits.TRISC1=0;
	TRISCbits.TRISC0=0;
	TRISCbits.TRISC3=0;
	TRISEbits.TRISE2=0;
	TRISEbits.TRISE1=0;
	TRISEbits.TRISE0=0;
	
	TRISBbits.TRISB5=0;
	TRISBbits.TRISB4=0;
	TRISBbits.TRISB3=0;
	TRISBbits.TRISB2=0;
	TRISBbits.TRISB1=0;
	TRISBbits.TRISB0=0;
	
	
	
	TRISCbits.TRISC6=0;
	TRISCbits.TRISC7=0;
	TRISDbits.TRISD4=0;
	TRISDbits.TRISD5=0;
	TRISDbits.TRISD6=0;
	TRISDbits.TRISD7=0;
	TRISDbits.TRISD0=0;
	TRISDbits.TRISD1=0; 
	TRISDbits.TRISD3=0; 
	TRISC=0;
	TRISD=0;
	TRISE=0;
	
	CS1=0;
	CS2=0;
	CS3=0;
	CS4=0;
	CS5=0;
	CS6=0;

first = 0;
second = 0;
third = 0;
fourth = 0;
fifth = 0;
sixth = 0;
	
	for(i=0;i<72;i++)
	{	
			
		DATA1=0;
		DATA2=0;
		DATA3=0;
		DATA4=0;
		DATA5=0;
		CS1=1;
		SDATA1=1;
		CLK1=0;
		CLK1=1;
		CLK1=0;
		
		CS1=0;
		
	}
	
	
	SDATA1=0;
	while(1)
	{

			
	//	first = title_row(first);
	
		first = title_row(first);	
		second = second_row(second);
	//	second = second_row(second);
	//	third = third_row(third);
	//	third = third_row(third);
	//	fourth = fourth_row(fourth);
	//	fourth = fourth_row(fourth);
	//	fifth = fifth_row(fifth);
	//	fifth = fifth_row(fifth);
	//	sixth = sixth_row(sixth);
	//	sixth = sixth_row(sixth);

	}	
}	

unsigned char title_row(unsigned int num1)
{	 
	first = num1;
	SDATA1=0;
	k=0;

		count++;
	if(count>30)
	{
		count=0;
		shifting1 += 1;
	}	
	
	 for(no_shift = 0; no_shift<10; no_shift++)
	 {
		 jk=0;
		 char_data_conv(str1[num1]);
		 
		 num1++;	 	 
		 
		
		 if(num1 > 46)
		 {
			 num1 = 0;
		 } 
		 char_data_conv(str1[num1]);

		 
		for(k=0;k<7;k++)
		{
			 shift_data = temp_array[k] >> shifting1;
			 
			 temp1 = temp_array[k + 7];
			 temp1 = temp1 << (5 - shifting1);
			 shift_data = shift_data | temp1;
			 
			 data_conversion(shift_data);
			CS1=1;
			CS1=0;
			
			 CLK1=0;
			 CLK1=1;
			 CLK1=0;
			 SDATA1=1;
			 if(no_shift==7)
			 {
				 CLK1=0;
				} 
		} 
		
		if(num1 > 46)
		{
			 num1 = 0;
		}
	 } 
	 
	 if(shifting1 >= 4)
	 {
		 first++;
		 
		 shifting1 = 0;
		 
	 } 
	 
	if(first > 46)
	{
	 	 first = 0;
	} 
		
	
	 
	 return first;
}	


unsigned char second_row(unsigned char num2)
{	 
	second = num2;
	SDATA2=0;
	k=0;
	
	count2++;
	
	if(count2>80)
	{
		count2=0;
		shifting2 += 1;
	}	
	
	 for(no_shift = 0; no_shift<10; no_shift++)
	 {
		 jk=0;
		 char_data_conv(str2[num2]);
		 num2++;
		 
		 
		 if(num2 > 52)
		 {
			 num2 = 0;
		 } 
		 char_data_conv(str2[num2]);

		 
		for(k=0;k<7;k++)
		{
			 shift_data = temp_array[k] >> shifting2;
			 
			 temp1 = temp_array[k + 7];
			 temp1 = temp1 << (5 - shifting2);
			 shift_data = shift_data | temp1;
			 
			 data_conversion(shift_data);
			CS2=1;
			CS2=0;
			
			 CLK2=0;
			 CLK2=1;
			 CLK2=0;
			 SDATA2=1;
			 		 
		} 
	
		if(num2 > 52)
		{
			 num2 = 0;
		}
	 } 
	 
	 if(shifting2 >= 4)
	 {
		 second++;
		 shifting2 = 0;
	 } 
	 
	if(second > 52)
	{
	 	 second = 0;
	} 
	 
	 return second;
}	


unsigned char third_row(unsigned char num3)
{	 
	third = num3;
	SDATA3=0;
	k=0;
	
	count3++;
	
	if(count3>80)
	{
		count3=0;
		shifting3 += 1;
	}	
	
	 for(no_shift = 0; no_shift<10; no_shift++)
	 {
		 jk=0;
		 char_data_conv(str3[num3]);
		 
		 num3++;		 	 
		 		 
		 if(num3 > 50)		// Remaining for all check the array then confirm with 45
		 {
			 num3 = 0;
		 } 
		 char_data_conv(str3[num3]);

		 
		for(k=0;k<7;k++)
		{
			 shift_data = temp_array[k] >> shifting3;
			 
			 temp1 = temp_array[k + 7];
			 temp1 = temp1 << (5 - shifting3);
			 shift_data = shift_data | temp1;
			 
			 data_conversion(shift_data);
			CS3=1;
			CS3=0;
			
			 CLK3=0;
			 CLK3=1;
			 CLK3=0;
			 SDATA3=1;
					 
		} 
	
		if(num3 > 50)
		{
			 num3 = 0;
		}
	 } 
	 
	 if(shifting3 >= 4)
	 {
		 third++;
		 shifting3 = 0;
	 } 
	 
	if(third > 50)
	{
	 	 third = 0;
	} 
	 
	 return third;
}	


unsigned char fourth_row(unsigned char num4)
{	 
	fourth = num4;
	SDATA4=0;
	k=0;
	
	count4++;
	
	if(count4>80)
	{
		count4=0;
		shifting4 += 1;
	}	
	
	 for(no_shift = 0; no_shift<10; no_shift++)
	 {
		 jk=0;
		 char_data_conv(str4[num4]);		 	 
		 num4++;
		 
		 if(num4 > 70)
		 {
			num4 = 0;
		 } 
		 char_data_conv(str4[num4]);

		 
		for(k=0;k<7;k++)
		{
			 shift_data = temp_array[k] >> shifting4;
			 
			 temp1 = temp_array[k + 7];
			 temp1 = temp1 << (5 - shifting4);
			 shift_data = shift_data | temp1;
			 
			 data_conversion(shift_data);
			CS4=1;
			
			CS4=0;
			
			 CLK4=0;
			 CLK4=1;
			 CLK4=0;
			 SDATA4=1;
			 
		} 
	
		if(num4 > 70)
		{
			 num4 = 0;
		}
	 } 
	 
	 if(shifting4 >= 4)
	 {
		 fourth++;
		 shifting4 = 0;
	 } 
	 
	if(fourth > 70)
	{
	 	 fourth = 0;
	} 
	 
	 return fourth;
}	


unsigned char fifth_row(unsigned char num5)
{	 
	fifth = num5;
	SDATA5=0;
	k=0;
	
	count5++;
	
	if(count5>80)
	{
		count5=0;
	//	shifting5 += 1;
	}	
	
	 for(no_shift = 0; no_shift<10; no_shift++)
	 {
		 jk=0;
		 char_data_conv(str5[num5]);		 	 
		 num5++;
		 
		 if(num5 > 75)
		 {
			 num5 = 0;
		 } 
		 char_data_conv(str5[num5]);

		 
		for(k=0;k<7;k++)
		{
			 shift_data = temp_array[k] >> shifting5;
			 
			 temp1 = temp_array[k + 7];
			 temp1 = temp1 << (5 - shifting5);
			 shift_data = shift_data | temp1;
			 
			 data_conversion(shift_data);
			CS5=1;
			CS5=0;
			
			 CLK5=0;
			 CLK5=1;
			 CLK5=0;
			 SDATA5=1;
			 
			 
		} 
	
		if(num5 > 75)
		{
			 num5 = 0;
		}
	 } 
	 
	 if(shifting5 >= 4)
	 {
		 fifth++;
		 shifting5 = 0;
	 } 
	 
	if(fifth > 75)
	{
	 	 fifth = 0;
	} 
	 
	 return fifth;
}	


unsigned char sixth_row(unsigned char num6)
{	 
	sixth = num6;
	SDATA6=0;
	k=0;
	
	count6++;
	
	if(count6>80)
	{
		count6=0;
	//	shifting6 += 1;
	}	
	
	 for(no_shift = 0; no_shift<10; no_shift++)
	 {
		 jk=0;
		 char_data_conv(str6[num6]);		 	 
		 num6++;
		 
		 if(num6 > 75)
		 {
			 num6 = 0;
		 } 
		 char_data_conv(str6[num6]);

		 
		for(k=0;k<7;k++)
		{
			 shift_data = temp_array[k] >> shifting6;
			 
			 temp1 = temp_array[k + 7];
			 temp1 = temp1 << (5 - shifting6);
			 shift_data = shift_data | temp1;
			 
			 data_conversion(shift_data);
			CS6=1;
			CS6=0;
			
			 CLK6=0;
			 CLK6=1;
			 CLK6=0;
			 SDATA6=1;
			 
			 
		} 
	
		if(num6 > 75)
		{
			 num6 = 0;
		}
	 } 
	 
	 if(shifting6 >= 4)
	 {
		 sixth++;
		 shifting6 = 0;
	 } 
	 
	if(sixth > 75)
	{
	 	 sixth = 0;
	} 
	 
	 return sixth;
}	


void char_data_conv(unsigned char alpha)
{
	switch(alpha)
	{
		case 'A':
				temp_no =0;
				break;
		case 'B':
				temp_no = 7;
				break;
		case 'C':
				temp_no = 14;
				break;
		case 'D':
				temp_no = 21;
				break;
		case 'E':
				temp_no = 28;
				break;
		case 'F':
				temp_no = 35;
				break;
		case 'G':
				temp_no = 42;
				break;
		case 'H':
				temp_no = 49;
				break;
		case 'I':
				temp_no = 56;
				break;
		case 'J':
				temp_no = 63;
				break;
		case 'K':
				temp_no = 70;
				break;
		case 'L':
				temp_no = 77;
				break;
		case 'M':
				temp_no = 84;
				break;
		case 'N':
				temp_no = 91;
				break;
		case 'O':
				temp_no = 98;
				break;
		case 'P':
				temp_no = 105;
				break;
		case 'Q':
				temp_no = 112;
				break;
		case 'R':
				temp_no = 119;
				break;
		case 'S':
				temp_no = 126;
				break;
		case 'T':
				temp_no = 133;
				break;
		case 'U':
				temp_no = 140;
				break;
		case 'V':
				temp_no = 147;
				break;
		case 'W':
				temp_no = 154;
				break;
		case 'X':
					temp_no = 161;
				break;
		case 'Y':
				temp_no = 168;
				break;
		case 'Z':
				temp_no = 175;
				break;
		case '.':
				temp_no = 182;
				break;
		case ',':
				temp_no = 189;
				break;
		case '&':
				temp_no = 196;
				break;
		
		case ' ':
				temp_no = 203;
				break;
				
	}
	
	
	for(j=0; j<7; j++)
	{
		temp_array[jk] = alphabets[temp_no];
		temp_no++; 
		jk++;
	}	
}	


void nop(void)
{
	unsigned int i=0;
	for(i=5;i>0;i--);
}	

void data_conversion(unsigned char data) //for latching ic 74hc373
{
	if(data & 0x01)
	{
		LATCbits.LATC3=1;
	}	
	else
	{
		LATCbits.LATC3=0;
	}	
	
	if(data & 0x02)
	{
		LATDbits.LATD0=1;
	}	
	else
	{
		LATDbits.LATD0=0;
	}	
	
	if(data & 0x04)
	{
		LATDbits.LATD1=1;
	}	
	else
	{
		LATDbits.LATD1=0;
	}	
	
	if(data & 0x08)
	{
		LATCbits.LATC5=1;
	}	
	else
	{
		LATCbits.LATC5=0;
	}	
	
	if(data & 0x10)
	{
		LATCbits.LATC4=1;
	}	
	else
	{
		LATCbits.LATC4=0;
	}	
	
}

My concept of the project is provide +5v through latching ic and GND through shift register to display.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top