Kinetis TWR-K60F120M ADC demo floating point math

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Kinetis TWR-K60F120M ADC demo floating point math

1,064 Views
kpointer
Contributor I

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?

Labels (1)
Tags (1)
0 Kudos
4 Replies

491 Views
Paul_Tian
NXP Employee
NXP Employee

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.

1.bmp

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

491 Views
kpointer
Contributor I

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

0 Kudos

491 Views
Paul_Tian
NXP Employee
NXP Employee


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.

Floating Point Setting.JPG

Hope my reply can help you.

Best Regards

Paul

491 Views
Paul_Tian
NXP Employee
NXP Employee

Hi, Kevin

I will test it in CodeWarrior IDE today. Please wait for me feedback.

Best Regards

Paul

0 Kudos