I've been modifying the ADC demo for the K60 tower board and have run into an issue with simple floating point math. Integer math works fine but any floating point math causes the debugger to jump to the default ISR. I can start a new project in CW with either the GNU or Freescale compiler and the math works fine.
static float var1 = 19990;
static float var2 = 65535;
uint8_t Hw_Trig_Test(void)
{
var1 = (float)(var1) / (float)(var2);
...
The above math crashes with the adc demo but works fine with new projects. Thoughts?
Hi, Kelvin
I tested your code in our sample project which is in IAR IDE. Path is ...\KINETIS_120MHZ_SC\build\iar\adc_demo. It can run well. Please find attached picuture.
I also can print ADC value by UART. So I think It should be your project has been changed.
Hope my reply can help you.
Best Regards
Paul
Thanks for testing this Paul! I re-downloaded the example code and I get the same failure. I wonder if it's a problem with the CodeWarrior 10.4 or the CW build of the example? Do you have CW installed?
Thanks,
-Kevin
Hi, Kevin
In CodeWarrior, you should do a setting as picture. Right click project then select properties -> Setting -> ARM CPU. Then change floating point from "Hardware vfpv4" to "software". Then you can do floating point operation as you need. This issue is caused by porting IAR code to CodeWarrior. IAR initial code is not including FPU module.
Hope my reply can help you.
Best Regards
Paul
Hi, Kevin
I will test it in CodeWarrior IDE today. Please wait for me feedback.
Best Regards
Paul