2
\$\begingroup\$

I will use this ARM to control Induction Motor with three-phase inverter. When the program encounters any float operations, like simple plus operation, the system hangs but the pause of debug works well. I increased the stack, I turned types as double, I increased the period that the interrupt ocorre (before 50us, changed to 1ms) however only work when this interrupt is turned off.

Kinetis K20 Without FPU CodeWarrior 10.4 Timer Overflow period 50uS Stack greater than 2048b Combined-complementary PWM mode

\$\endgroup\$
  • 5
    \$\begingroup\$ Is it fair to ask if you can just avoid using floats? With int32_t and int64_t, you can just make your units fine enough for integer math to do fine (i.e., instead of 92 degrees, use 92000 thousandths of a degree)? Unless its something critical like pole placement, this is usually better use of resources than using floats. You just need to remember to do your multiplies before your divides! \$\endgroup\$ – Scott Seidman Apr 8 '14 at 22:38
  • 1
    \$\begingroup\$ @SeanBoddy, especially if you can work out your scaling in advance to make all of your divides are powers of two shifts! \$\endgroup\$ – Scott Seidman Apr 8 '14 at 22:56
  • 1
    \$\begingroup\$ @fabio, all I can say is that its very rare for me to need to do floating point ops on an embedded platform. All of my inputs from every peripheral are ints, all of my multipliers are ints (even if I need to scale them up), my PWM parameters are ints, and so on. Since I started programming on 8-bit microcontrollers in the '80s, I haven't needed to use a floating point operation. With 64 bit math, you can get real low fixed point errors if you toss floats right out of your toolbox. \$\endgroup\$ – Scott Seidman Apr 8 '14 at 23:05
  • 2
    \$\begingroup\$ I would also point out that your platform holds up your design. Making the economic decision to use a particular part comes with the responsibility of playing to its strengths. If I read the original post correctly, your platform is not equipped with a floating point unit. If floating point data becomes crucial to the application, it may be time to reevaluate your choice of platform. \$\endgroup\$ – Sean Boddy Apr 8 '14 at 23:25
  • 1
    \$\begingroup\$ Especially considering that if an FPU is desired, the higher-end MCUs in the K20 line add it. They're even pin compatible. \$\endgroup\$ – Peter Apr 8 '14 at 23:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy