Hi,
I am at the moment testing a Cortex M3 (Evaluation Board with Toshiba TMPM330). I am thinking about realising a controller on it in combination with the RTX-RL OS. This requires massive usage of filters as well as differentiation.
Usually, building this thing in university, I can simply use floating points and everything is fine. Due to the fact that the Cortex M3 only emulates floating point operations, I do wonder if this causes massive performance issues and if there are any other limitation. Using it with usually integers or similiar is not really a great alternative.
Has anyone experience and can recommend me ideas? Is it fine if I just use the floating point code, can I avoid some issues by simple adjustments or do I have to code it in fixed point.
Thank you
Christian
You'd have to state your specific performance requirements. Floating point operations do take considerably more time than integer ones, but only you can decide if they are too slow for you. You can easily measure execution time of your code in Keil's simulator.
Is there just a rule of thumb a la multiplication in floating takes 5x the time of fixed point operations? I can be very rough that's fine for me. Just to get an idea.
I did a quick test for you:
volatile int i[3] = { 1, 2, 3 }; volatile float f[3] = ( 1, 2, 3 }; int main(void) { i[0] = i[1] * i[2]; f[0] = f[1] * f[2]; }
The integer multiplication took 7 cycles, of which 4 cycles were used to load operands and 2 cycles - to store the result. The multiplication itself is 1 cycle, in accordance with 'hardware single-cycle multiply' promise of Cortex-M3. The float multiplication took 47 cycles with the multiplication itself taking 41 cycles. Keep in mind that the float multiplication execution time depends on the values of operands.
Using it with usually integers or similiar is not really a great alternative.
Maybe you could explore fixed-point arithmetics as an alternative? The CM3 is quite fast with 64-bit math, faster than floating-point.
And floating point arithmetics bring their own set of possible pitfalls, especially in control engineering and signal processing.