AnsweredAssumed Answered

Timing to do multiplication and divide

Question asked by Byron Dally on Jun 15, 2010
Latest reply on Jun 17, 2010 by Byron Dally

Hi

 

Hardware: MS9SO8GT60 with 32.768 kHZ xtal

programmer: Cyclone Pro HC08 - HCS08

IDE: Freescale Codewarrior 5.9.0

 

 

I seem to be having a timing issue with how long it takes to perform the calculation, and then assigning the computed value.

I assumed it wouldnt move to the next step, before the calculation had finished, but when I step through the code, it looks like it assigns 'tempunit' to activeArray before the value is finished calculating. and therefore, assigns '0'.

 

so all this is doing is a 6 digit number (date) and putting it into a 3 byte array (activeArray)

so for example 

 

divisor = 10/06/02

 

then activeArray should be [ 10, 6, 2 ];

 

but it ends up being [0, 6, 2]

 

 

  for (i=0;i<=2;i++){        tempunit = (BYTE)(divisor%10);    divisor /= 10;    //new value to mod by 10        temptens =  (BYTE)(divisor%10);    temptens *= 10;    temptens += tempunit;    activeArray[j] = tempunit;    j--;    divisor /= 10;    //new value to mod by 10      }

 

is this possible?

Outcomes