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 support@ccsinfo.com

clock issue

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



Joined: 17 Apr 2007
Posts: 20
Location: tijuana,bajacalifornia,mexico

View user's profile Send private message MSN Messenger

clock issue
PostPosted: Wed Jul 16, 2008 1:57 pm     Reply with quote

Hi:

I have a doubt, I have been working with PICs, and sometimes I use crystal as oscillator, other times I use the internal oscillator, and actually I have never used the crystal for any specific propose, but in my last project, I need precision on my system, due to I am developing an irrigation system, and it includes a 24 hrs clock, I am using the rtcc timer interrupt, at 1 sec,
Code:

#FUSES XT                       //Crystal osc <= 4mhz
......
#use delay(clock=4000000)
.......
#int_RTCC
RTCC_isr()
{
   masters++;
   if(masters==60)
   {
      masterm++;
      masters=0;
   }
   if(masterm==60)
   {
      masterh++;
      masterm=0;
   }
   if(masterh==24)
      masterh=0;
      lcd_gotoxy(2,1);
      printf(lcd_putc,"%02u:%02u:%02u  ",masterh,masterm,masters);
}
..........
void main()
{
..........
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_16);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   enable_interrupts(INT_RTCC);
   enable_interrupts(GLOBAL);
   setup_oscillator(False);
.......



I am just posting the necessary code to define what I am doing to make a clock, in my code the variable masterh, masterm and masters represents the hours, minutes and second of the master clock (there are two more clocks or times), in this way the simulation works, and works great, my question is (finally), in the simulation it works fine but I let the simulation running 45 minutes but the clock in the lcd in the simulator just advanced 40 minutes, I am waiting for an LCD to mount the circuit but, what I must expect in my circuit, will it work on time or the simulator its showing me the real behavior, (the simulator it is proteus but I know that this is not a proteus forum).

some that I would appreciate is if someone has a working code of a clock, even a basic one.

thanks in advance.
_________________
Every little thing gonna be alright
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

PostPosted: Thu Jul 17, 2008 7:31 am     Reply with quote

See:
http://www.ccsinfo.com/forum/viewtopic.php?t=26177
Also, the lcd_gotoxy and printf should be moved from the isr into a loop in your mainline code.
_________________
Andrew
elphi



Joined: 17 Apr 2007
Posts: 20
Location: tijuana,bajacalifornia,mexico

View user's profile Send private message MSN Messenger

thanks
PostPosted: Fri Jul 18, 2008 2:09 pm     Reply with quote

Yep, this is the code I needed. thanks men it works great.

PS. I moved the lcd instructions from the isr, but actually i don't think that this were important, but just for the flys as we say in Mexico.
_________________
Every little thing gonna be alright
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