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

start and stop the process
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Wed Jan 13, 2010 6:21 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Jan 13, 2010 8:41 am     Reply with quote

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







PostPosted: Wed Jan 13, 2010 10:16 am     Reply with quote

hayee wrote:
From where i get the mktime function.

rtctimer.c

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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