CANpack code generation Problem for MCU without floating-point math capabilities
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
zhichao li
am 16 Sep. 2023
Beantwortet: zhichao li
am 17 Sep. 2023
real32_T outValue = 0;
{
real32_T result =aa;
result =bb;
outValue = roundf(result);
"This facility may not be available on configurations of the EWL that run on platforms
that do not have floating-point math capabilities. "
--EWL C Reference Manual.pdf
Akzeptierte Antwort
Walter Roberson
am 17 Sep. 2023
Bearbeitet: Walter Roberson
am 17 Sep. 2023
roundf has been part of the C standard library since C99. However it expects floating point input and returns floating point output, which is a problem if you are using a system that does not have floating point hardware.
On a system that does not have floating point hardware, you have two choices:
- you can carefully write your code to only operate on the int* and uint* classes; or
- you can convert your code to use fixed-point arithmetic with the Fixed-Point Toolbox. The fixed point toolbox can emulate many floating-point operations in software, including potentially to greater precision than double precision floating point. However, transcendental functions such as trig functions or log generally have to be rewritten; search for CORDIC for those.
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Trigonometry finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!