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

Software Real Time Clock

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



Joined: 08 Sep 2011
Posts: 202

View user's profile Send private message

Software Real Time Clock
PostPosted: Sun Jan 15, 2012 11:11 am     Reply with quote

For Real Time Clock we can use this ??
Code:

#use delay(clock=4000000)

Code:

/********************************************************
  Timer1 Interrupt, executed every 10 ms
********************************************************/
#INT_TIMER1
void TIMER1_isr(void)
{
   // Increment time_elasped to keep track of ms
   time_elasped++;
   // Increment seconds variable if 1000 ms have passed
   
   if (time_elasped == 100)  //@ 1000 ms
   {
        seconds++;
        time_elasped = 0;
   }
   //Reset Timer 1
   set_timer1(60545);
   clear_interrupt(INT_TIMER1);   
}

its right ???
_________________
sahu
temtronic



Joined: 01 Jul 2010
Posts: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Jan 15, 2012 1:20 pm     Reply with quote

Why don't you just use the working software RTC that's in the code library?

What you posted isn't even close to being a real program, so we have no way of knowing that it might work.

BTW one problem with sw rtc is they only run when the PIC is powered ! I've gone to using the DS1307 in my products.The other is the sw overhead(space, time,etc.)
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sun Jan 15, 2012 1:23 pm     Reply with quote

It helps when you post a complete program. Now we have to guess as to what processor you are using and the configuration of the Timer1 is missing. Without this we can not tell if it is correct or completely wrong.
You've been a member of this forum for so long now that you should know we always ask for a complete program and you are proofing us to be right again.

Explain how you got to the magic value of 60545. It sounds to be very close to a correct value but depends very much on compiler version and other details. I would like to hear your reasoning.

Clearing the Timer1 interrupt is not required, the compiler will do it automatically. Now it is being cleared twice, a waste of memory and processing power.
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