I am guessing a bit, but try:- STEPPER.brakeDistance = (unsigned long) ((STEPPER.maxSpeed+STEPPER.minSpeed)*(STEPPER.maxSpeed-STEPPER.minSpeed))/(2*STEPPER.acceleration);
Of course, you could declare all the relevant variables unsigned longs and not bother with the cast. FWIW, I have had trouble with code like this because the libraries are not reentrant and when interrupts are involved things went quite weird, but that was Z80 code...? I'm not familiar with the PIC in question, but are you sure a long is as 'long' as you think it is!? On Sunday 18 January 2009 10:49:45 Kustaa Nyholm wrote: > Hi, > > a bit early to ask this but it may take a few hours before I can > actually see what values I'm getting > (my usart/serial port is not functioning at the moment) so I might as > well ask here. > > Is there something to I need to do to enable support for 32 bit arithm > ops? > > It appears that the following statement: > > STEPPER.brakeDistance = ((unsigned > long)(STEPPER.maxSpeed+STEPPER.minSpeed))*(STEPPER.maxSpeed-STEPPER.minSpee >d)/(2*STEPPER.acceleration); > > does not produce what I would expect. > > With the following values > maspeed = 5000 > minspeed = 300 > acceleration = 10000 > > this should give > > breakDistance = 1245 > > but judgin from the behavior of the motors this is not happening. If I > manuallu put in the correct breakDistance then this works. > > Yeah, would be better if I had some actual faulty values to show, but > that will take some hours..or days. > > Meanwhile, anything obvious in my code? > > Do I need to recompile SDCC libraries or some such? > > br Kusti > <snip> -- Richard. PGP Key-id: 0x5AB3D350 George Orwell was an optimist. ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user