Hello, iam using MSP430FR6989. Are there any limitations while using the double or float data types with this controller ?
I need to calculate this equation:
TOF = (2147)(5.4 *10^-11) + (318)(1/8MHZ) - (201)(5.4 * 10^-11) ;
Thank you
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello, iam using MSP430FR6989. Are there any limitations while using the double or float data types with this controller ?
I need to calculate this equation:
TOF = (2147)(5.4 *10^-11) + (318)(1/8MHZ) - (201)(5.4 * 10^-11) ;
Thank you
Ahmed,
of course you can do this. But take care when writing this equation - for example there is no "^" in C. You can use the pow-function of the math.h for that. And don't forget that things like (1/8) are treated as integer which results in 0. Furthermore expressions like (operand)(operand) do not work as well since they need the operator "*" in between. But in general you can do this - the syntax must be correct and the datatypes must be chosen according to your requirements.
And don't forget that the MSP430 has no floating point unit, so calculations like this are quite slow. I don't know what the variable is in your case because your expression could also be calculated before code execution since it is a constant, but try to pre-calculate as much as possible before runtime and simply use this as a constant coefficient.
Dennis
The floating point calculations are substituted by operations the MSP can handle. That is why floating point calculations need much code size and are very slow.
Ahmed Kamel Hasanein said:are they safe and reliable
Of course they are! Don't worry about that - the results will be correct :)
Ahmed Kamel Hasanein said:Can i use (e) instead of(^)
Be careful - don't mix "^", "e" and "E". 2^3 is different to 2E3. You can write a floating point number as 1.6E+3 for 1600, for example.
Ahmed Kamel Hasanein said:where can i find the (math.h) library
Simply add
#include <math.h>
This file should be part of your IDE already. Look at the functions it contains:

Dennis
**Attention** This is a public forum