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.

[PIC] How to update lcd in one second ?

Status
Not open for further replies.

anjalimidhuna

Member level 3
Member level 3
Joined
Jan 4, 2014
Messages
62
Helped
2
Reputation
4
Reaction score
2
Trophy points
8
Location
india
Visit site
Activity points
358
Hi all,
i am using PIC16F877A and LCD in 4 bit mode. how can i update the display routine in one second ?
 

hello

LCD refresh need less than 1 sec .. you can refresh it every 100mS, an maybe less..
Only the LCD init can take more than 500mS ...but you do it only once at startup of program.
after , it 's depend what you are doing into the main loop of your program..

Show us your program application...
 

Actually i meant, i wanna hold the display for one second in the screen . now wrote a simple delay function using for loop. but it is not efficient. is there any other option for that ??
 

A 2x16 character display can be updated in less than 10 ms, using either 4- or 8-bit mode (if coded appropriately).

For a periodical refresh, you'll probably want to use a timer or a flag set in a timer interrupt.
 

please correct me ... :)

Code:
void interrupt(void)
{
	unsigned int countForTmr=0,j=0;
	if(PIR1.TMR1==1)
	{
		countForTmr++;
		display(j);					
		j++;
		if(j>=5)
		{j=0;}
		countForTmr=0;	
	}
}
 

???
does it means LCD display disappears if delay 1 second ?
I don't understand what is the problem .
Actually the display changes to some junk after showing the display once.

- - - Updated - - -

???

Show your code !
this is my code.
Code:
typedef struct display
{
const char *name[8];		
const char *unit[8];		
}disp;


void main()
{
	unsigned char i=0;			
	disp d;						
	Lcd_Init();				
	while(1)
	{	
		LCD(Lcd_clear,ModCmd);			
		Delay_ms(100);					
		LCD(FstLin_FstColumn,ModCmd);

		if(i<=7)
		{
		d.name[i]=name[i];				
		d.unit[i]=unit[i];				
		Disp_STRING(d.name[i]);			
		Disp_STRING(d.unit[i]);			
		i++;	
		}
		else
		{
		i=0;
		}
		Delay_ms(100);	
	}
}
 

PB, in your interrupt routine

Code:
void interrupt(void)
{
	unsigned int countForTmr=0, j=0;
	if(PIR1.TMR1==1)
	{
		countForTmr++;  // you increment it, and after put zero ???
		display(j);	 //[COLOR="#FF0000"][B] if it is LCD display, you can not use it, into the interrupt routine!!![/B][/COLOR]				
		j++;
		if(j>=5)
		 {
			j=0;
		}
		countForTmr=0;	[B][COLOR="#FF0000"]// so it is always zero value ? what purpose ??[/COLOR][/B]
      [B][COLOR="#FF0000"] PIR1.TMR1=0;[/COLOR][/B] // don't forget !
	}
}

try this change

Code:
volatile int Flag;
volatile int  countForTmr;

void interrupt(void)
{
unsigned int j=0;
if(PIR1.TMR1==1)
{
	countForTmr++; 
	j++;
	if(j>=5)
	 {
		j=0;       // if you want to display every 5 interrupt
		Flag=1;  // 
	}
 PIR1.TMR1=0;		
 }

}


void main()
{

... your application
Init timer

Flag=0;
CountForTmr();
// enable here interrupt 

While(1)  // main loop
{

if (Flag==1) 
{
   Diplay(CountForTmr);
  Flag=0;
 CountForTmr=0 ; // if needed ..!!
 }
......
....
}


where is the code for Disp_STRING(d.name); ?
 

    V

    Points: 2
    Helpful Answer Positive Rating
where is the code for Disp_STRING(d.name); ?


i wrote it in the header file.
Code:
void Disp_STRING(const char *d)
{
	while(*d)
	{
	LCD(*d,ModData);		// DISPLAY EACH CHARECTOR OF THE STRING
	Delay_ms(10);		
	d++;
	}
	d=0;
}
will try your code and feedback soon :smile: thanks for your help :grin:

- - - Updated - - -

hello paul,
sorry to disturb you .i tried your code.but don no how to rectify this error.
Error [285] F:\PROJECTS\INVERTERmplab\dispnew.c; 32.1 no identifier in declaration
Error [314] F:\PROJECTS\INVERTERmplab\dispnew.c; 32.1 ";" expected
please help me :(
 

Without seeing all your code.. an maybe external files *.c and *.h
impossible to help you..
you, only, knows where is dispnew.c file .
check in your project all path for external files..
 

This is what I understood from your question

Use Timer1 external oscillator mode with interrupt for one second delay
That will help you to change display characters every one second
 


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
void Disp_STRING(const char *d)
{
    while(*d)
    {
    LCD(*d,ModData);        // DISPLAY EACH CHARECTOR OF THE STRING
    Delay_ms(10);       
    *d++;
    }
    d=0;
}



In interrupt routine Timer1 value is not reloaded. When data to be displayed on LCD changes then only call the LCD display (refresh) function.
 

Without seeing all your code.. an maybe external files *.c and *.h
impossible to help you..
you, only, knows where is dispnew.c file .
check in your project all path for external files..
thax paul i corrected the error. i changed the interrupt function name to isr . :) it works :)

- - - Updated - - -

This is what I understood from your question

Use Timer1 external oscillator mode with interrupt for one second delay
That will help you to change display characters every one second

thax pa3040 for your valuable comment :)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top