CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

ds1307+lcd

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
nina



Joined: 20 Apr 2007
Posts: 111

View user's profile Send private message Send e-mail

ds1307+lcd
PostPosted: Mon Mar 23, 2009 6:30 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Mar 23, 2009 6:52 am     Reply with quote

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

View user's profile Send private message Send e-mail

solved
PostPosted: Mon Mar 23, 2009 7:10 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group