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

Calculation

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







Calculation
PostPosted: Wed Feb 25, 2004 9:22 am     Reply with quote

I tried to do this math operations and when i do it my pic stop to respond. It doesnt do rest of my code can you tell me why.

iJour = ((23*iMois/9) + 1 + 4 + iAnnee + (z/4) - (z/100) + (z/400) - 2);

If i put it in comment all my code function. If it is not in comment my code doesnt function.
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Wed Feb 25, 2004 10:02 am     Reply with quote

Without seeing the rest of your code we can only guess.

So here are some guesses:

1) you are exceeding the watchdog timer value and so the PIC is resetting
2) there may be a compiler bug and so look at the generated assembly listing to see if the PIC is stepping on itself

Try and write the shortest possible program that still has this problem and post that listing.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Wed Feb 25, 2004 4:37 pm     Reply with quote

That is a lot of math in one line. Try to break in up into several lines with only 2 or 3 math operators each. That makes it easier for the compiler, and a lot easier to read the .lst file.
_________________
The search for better is endless. Instead simply find very good and get the job done.
Marcus
Guest







PostPosted: Thu Feb 26, 2004 10:37 am     Reply with quote

I already broke my code in many lines. But it is possible that compilator connot divide a float expression and put it in a int var. By example,

int i = 9;

i = i / 2;
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Thu Feb 26, 2004 10:53 am     Reply with quote

Marcus wrote:
I already broke my code in many lines. But it is possible that compilator connot divide a float expression and put it in a int var. By example,

int i = 9;

i = i / 2;


This will be 4. If you ment for it to be 4.5 then "i" should have been defined as a float in the first place and you should either make the "2" a "2.0" or cast it with "(float)2".
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
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