 |
 |
| View previous topic :: View next topic |
| Author |
Message |
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Wed Jan 13, 2010 6:21 am |
|
|
Your problem is most likely to be the maths.
At first glance it all looks fine but you need to think about how the PIC is going to do the maths.
Your variables are 8 bit values except for start_time and end_time.
unsigned int hour1=0,hour2=0,min1=0,min2=0,sec1=0,sec2=0;
This is where I see the problem:-
start_time=(hour1*3600)+(min1*60)+sec1;//values are stored in eeprom
stop_time=(hour2*3600)+(min*60)+sec2;//values are stored in eeprom
The pic will do the following maths where
hour1 = 19
min1 = 50
sec1 = 40
start_time=(hour1*3600)+(min1*60)+sec1;
(hour1 *3600) Assuming the 3600 forces the compiler into 16bit maths :- (19 * 3600) = 2864
(min1 * 60) with 8 bit maths (50 * 60) = 184
try :-
start_time=((int32)hour1*3600)+((int16)min1*60)+sec1; |
|
 |
John P
Joined: 17 Sep 2003 Posts: 331
|
|
Posted: Wed Jan 13, 2010 8:41 am |
|
|
That certainly sounds plausible. And of course with the original version of the program,
if((hour==hour1)&(min==min1)&(sec==sec1))//start time
there wasn't any calculation involved, just comparisons, so the problem didn't occur, even if other problems did. |
|
 |
Ttelmah Guest
|
|
Posted: Wed Jan 13, 2010 10:16 am |
|
|
| hayee wrote: | | From where i get the mktime function. |
rtctimer.c
Best Wishes |
|
 |
|
|
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
|