Why does this execute differently when plugged into the BDM?

Discussion created by Guest on Sep 25, 2010
Latest reply on Sep 27, 2010 by Daniel Lundin

I have a line of code running on a 9S12XEP that seems to run differently when the micro is plugged into the BDM than it does when it isn't plugged into the BDM.

 

 

signed int P_gain_tb = 500;signed int P_val_tb = 0;signed long int PID_tb_result = 0;...PID_tb_result = ((P_gain_tb) * (long)(P_val_tb));

 

When the BDM is plugged in and the BDM resets the micro, the code evaluates as I expect. That is P_gain_tb * a positive value between 0 and 1000 for P_val_tb = a positive value for PID_tb_result. And if P_val_tb is negative, the line of code evaluates so that PID_tb_result is negative.

 

The problem is when i run the micro without being plugged into the BDM (reset the micro myself), the exact opposite happens. Somehow it evaluates negative when it should be positive, and vise versa.

 

How is this related to the BDM at all? I'm going crazy.

 

Brad

Outcomes