View previous topic :: View next topic |
Author |
Message |
nina
Joined: 20 Apr 2007 Posts: 111
|
ds1307+lcd |
Posted: Mon Mar 23, 2009 6:30 am |
|
|
Trying simulate the code below I observe the timer showed on lcd is not the same that from proteus. There is a kind of delay. How can I improve it?
Another problem is when it reach the line
Code: | if ((hora==0x21) && (min==0x15) && (sec==0x03) || status == 0) { | the message blink and I don't want it blink. I want the message TESTING not blink on LCD.
tks
nina
Code: | #include <16F877.h>
#include <ds1307.c>
#include <stdio.h>
#use delay(clock=4000000)
#include <lcd.c>
void main() {
byte hora,min,sec;
int status = 1;
init_ds1307();
hora=write_ds1307(2,0x21);
min=write_ds1307(1,0x15);
sec=write_ds1307(0,0x00);
while (1) {
sec=read_ds1307(0);
hora=read_ds1307(2);
min=read_ds1307(1);
lcd_init();
lcd_gotoxy(1,1);
printf(lcd_putc,"Hora: %2X:%2X:%2X",hora,min,sec);
delay_ms(200);
if ((hora==0x21) && (min==0x15) && (sec==0x03) || status == 0) {
lcd_gotoxy(1,2);
printf(lcd_putc,"TESTING");
delay_ms(200);
status = 0;
}
}
} |
|
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Mon Mar 23, 2009 6:52 am |
|
|
What do you want to improve? Proteus?
Quote: | the message blink and I don't want it blink. | I see that you are continuously re-initializing your LCD display. This can't result in meaningful operation, seriously.
Also your additional text is displayed and then deleted after 200 ms, repeatedly. You simply may want to think about
the intended execution flow of your code and correct it accordingly. |
|
|
nina
Joined: 20 Apr 2007 Posts: 111
|
solved |
Posted: Mon Mar 23, 2009 7:10 am |
|
|
Thank you very much FvM
I change the lcd_init() from the while loop to the main() and it worked perfectly.
thank you very much
nina |
|
|
|