AnsweredAssumed Answered

Function returns illogical value at runtime, but returns correct value during debug.

Question asked by Chris Belsky on Oct 29, 2010
Latest reply on Oct 29, 2010 by bigmac



I'm running an application in the HCS08DZ60A microprocessor written in C.  I have a function that crunches a 5th-order polynomial and returns the result.  All variable types are 'float'.  Here are the bug symptoms:


1) The poly function returns an incorrect value when executing real-time in the platform.  However, if I step through the function using CodeWarrior Real-Time Debugger through the BDM port, the function returns the correct value.


2) The format of the function is:  float F_polyf(unsigned char n, float *Coef, float x) where x is the input value, *Coef is a pointer to an array of the coefficients, and n is the number of coefficients.


3) I've been using this same poly function for 5 years in both the HC08AZ60A and HCS08DZ60A and it has always worked.  Now this time around, my application simply involved a 'minor' update to a seemingly unrelated area and after recompile the bug has appeared. 


4) The bug only appears after a hardware power-up / reset.  If I exercise the product a bit after power-up, the bug clears up.


5) I've verified my 'logic' with the CodeWarrior Real-Time Debugger. When stepping through the function with the debugger, the math comes out correctly.  Thus, my issue seems related to something else.


6) I call this function in four different locations in my program, but the 'bug' only appears at one of the locations.  The other three locations always calculate correctly. 


Has anyone seen any symptoms like these?  I've run out of ideas, and I'm just looking for somewhere to go. 


Thanks much,