![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
elphi
Joined: 17 Apr 2007 Posts: 20 Location: tijuana,bajacalifornia,mexico
|
clock issue |
Posted: Wed Jul 16, 2008 1:57 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
andrewg
Joined: 17 Aug 2005 Posts: 316 Location: Perth, Western Australia
|
|
![](templates/subSilver/images/spacer.gif) |
elphi
Joined: 17 Apr 2007 Posts: 20 Location: tijuana,bajacalifornia,mexico
|
thanks |
Posted: Fri Jul 18, 2008 2:09 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|