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?

Hello,

Assuming the initial value of the variable divisor is the unsigned 16-bit value 100602 (not entirely clear from your post), the initial value of variable j is 2, and that you complete the loop three times, rather than twice, I would expect to get the result 0, 6, 2.

I think your problem is with the line activeArray[j] = tempunit;

It would seem that the expression should be activeArray[j] = temptens;

Perhaps the code might be simplified, as follows

:

Regards,

Mac