View previous topic :: View next topic |
Author |
Message |
Marcus Guest
|
Calculation |
Posted: Wed Feb 25, 2004 9:22 am |
|
|
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
|
|
Posted: Wed Feb 25, 2004 10:02 am |
|
|
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
|
|
Posted: Wed Feb 25, 2004 4:37 pm |
|
|
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
|
|
Posted: Thu Feb 26, 2004 10:37 am |
|
|
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
|
|
Posted: Thu Feb 26, 2004 10:53 am |
|
|
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! |
|
|
|