hi,

I'm using HCS08 family controller(MC9S08GB60).In the code i'm using some global variables like x,y,z.The values of global variable changes as required.But while executing following statement (mathematical) the values of global variable changes to unknown value.The statement is as below

a=(unsigned long int)((vtg_r_max1 * vtg_r_max1)+(vtg_y_max1 * vtg_y_max1)+(vtg_r_max1 * vtg_y_max1));

b=(unsigned long int)((vtg_y_max1 * vtg_y_max1)+(vtg_b_max1 * vtg_b_max1)+(vtg_y_max1 * vtg_b_max1));

c=(unsigned long int)((vtg_b_max1 * vtg_b_max1)+(vtg_r_max1 * vtg_r_max1)+(vtg_b_max1 * vtg_r_max1));

The above statement is just in the form of (a2+b2+ab).And the global variable x,y,z have no relationship with this expression.

b=(unsigned long int)((vtg_y_max1 * vtg_y_max1)+(vtg_b_max1 * vtg_b_max1)+(vtg_y_max1 * vtg_b_max1));

c=(unsigned long int)((vtg_b_max1 * vtg_b_max1)+(vtg_r_max1 * vtg_r_max1)+(vtg_b_max1 * vtg_r_max1));

The above statement is just in the form of (a2+b2+ab).And the global variable x,y,z have no relationship with this expression.

Can you suggest me the sollution for changes in global variable value upon executing each expression.

With regards

santhu

Added p/n to subject.

Message Edited by NLFSJ on 2008-07-24 07:28 AM

calculation using long variable.Is there is any calculation for increasing stack size.What is the max value we can give for stack in 8 bit controller of 64k.Codewarrior keeps local Variables on the Stack, so by using long, much stack space is used ( 4 Bytes for each long variable ). The max value for the stack size is given by the RAM size. For gte GB60 this is 4 KB.

You can use Stacktop instead of Stacksize to put the Stack to the Top of the RAM area.

Eckhard.