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

glcd+rtc

 
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

glcd+rtc
PostPosted: Wed Mar 25, 2009 10:48 am     Reply with quote

When I simulate this code on Proteus, the variable secs count seconds but it doesn't erase the last value. I mean, it count 00 and 01 it is written over 00.
How can I solve this?

tks

nina
Code:
#include <16F877.h>
#use delay(clock=4000000)
#include <glcd.c>
#include <ds1307.c>


void main()
{
byte hora,min,sec;
int status = 1;
char secs[8];
init_ds1307();
sec=write_ds1307(0,0x00);


delay_ms(100);
glcd_init(ON);
glcd_fillScreen(OFF);

while(TRUE){
   sec=read_ds1307(0);
   sprintf(secs, "%X", (byte)sec); // Converts sec to text
   glcd_text57(1, 1, secs, 1, ON);
   }

}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 25, 2009 3:19 pm     Reply with quote

Think about the problem. If a write-character routine is overlaying new
characters on top of existing characters, what can you do about it ?

Think. You would want to erase the old character before you write a
new one. How can you do that ? I can think of at least two ways.

What character could you write over the old one to erase it ?
What character would erase all other characters, if you write it on
top of an existing character ?

Or, what option does the glcd_text57() routine have (as a parameter),
to change the color of the character dots ? How can this option be
used to erase a previous character ?
nina



Joined: 20 Apr 2007
Posts: 111

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

glcd+rtc
PostPosted: Wed Mar 25, 2009 6:59 pm     Reply with quote

PCM programmer..

thank you for your comments...I tried to do this, but now secs keep blinking...

Code:
#include <16F877.h>
#use delay(clock=4000000)
#include <glcd.c>
#include <ds1307.c>


void main()
{
byte hora,min,sec;
int status = 1;
char secs[8];

init_ds1307();
sec=write_ds1307(0,0x00);


delay_ms(100);
glcd_init(ON);
glcd_fillScreen(OFF);

while(TRUE){
   sec=read_ds1307(0);
   sprintf(secs, "%X", (byte)sec); // Converts sec to text
   glcd_text57(15, 15, secs, 1, ON);
   glcd_text57(15, 15, secs, 1, OFF);
   }

}
PICoHolic



Joined: 04 Jan 2005
Posts: 224

View user's profile Send private message

PostPosted: Thu Mar 26, 2009 5:49 am     Reply with quote

try this:

Code:

#include <16F877.h>
#use delay(clock=4000000)
#include <glcd.c>
#include <ds1307.c>


void main()
{
byte hora,min,sec;
int status = 1;
char secs[8] = {0};

init_ds1307();
sec=write_ds1307(0,0x00);


delay_ms(100);
glcd_init(ON);
glcd_fillScreen(OFF);

while(TRUE){
   sec=read_ds1307(0);
   glcd_text57(15, 15, secs, 1, OFF);
   sprintf(secs, "%X\0", (byte)sec); // Converts sec to text
   glcd_text57(15, 15, secs, 1, ON);
   delay_ms(1000);
   }

}

nina



Joined: 20 Apr 2007
Posts: 111

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

PostPosted: Thu Mar 26, 2009 6:57 am     Reply with quote

PICoHolic...

I tried do this but the problem was time is not right because of delay.
That is the point...I thought do this way...

Do you have another way to solve this problem?
I want to display hour, min, sec

tks

nina
PICoHolic



Joined: 04 Jan 2005
Posts: 224

View user's profile Send private message

PostPosted: Thu Mar 26, 2009 7:05 am     Reply with quote

Quote:

I tried do this but the problem was time is not right because of delay.


The delay_ms(1000) is just for the display. The 1 second timing is coming from your DS1307 RTC.

I suggest that you feed the output of the DS1307 (1 sec clock) into one of your external interrupts and then update your display accordingly.

Good Luck
nina



Joined: 20 Apr 2007
Posts: 111

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

glcd
PostPosted: Thu Mar 26, 2009 7:23 am     Reply with quote

but if i have a delay_ms(1000) inside a while loop and inside of this while loop I get reading from ds1307, so for sure I will have a delay between the real time( from ds1307) and the reading of ds1307.

tks again

nina
PICoHolic



Joined: 04 Jan 2005
Posts: 224

View user's profile Send private message

PostPosted: Thu Mar 26, 2009 7:39 am     Reply with quote

Yes, but not that important...
Anyway if you insist on having it in a loop inside your main, try this out:


Code:

#include <16F877.h>
#use delay(clock=4000000)
#include <glcd.c>
#include <ds1307.c>


void main()
{
byte hora,min,sec, old_sec = 0xFF;
int status = 1;
char secs[8] = {0};

init_ds1307();
sec=write_ds1307(0,0x00);


delay_ms(100);
glcd_init(ON);
glcd_fillScreen(OFF);

while(TRUE){
   sec=read_ds1307(0);
   if (old_sec != sec) {
      glcd_text57(15, 15, secs, 1, OFF);
      sprintf(secs, "%X\0", (byte)sec); // Converts sec to text
      glcd_text57(15, 15, secs, 1, ON);
      old_sec = sec;
      }
   }

}
nina



Joined: 20 Apr 2007
Posts: 111

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

gldc+rtc
PostPosted: Thu Mar 26, 2009 12:49 pm     Reply with quote

very nice...it is working..

Thanks you very much PICoHolic

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