How to do floating point operation in Q format(S912ZVML32)

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

How to do floating point operation in Q format(S912ZVML32)

Jump to solution
1,017 Views
maxxu
Contributor IV

Hi

   Hello everyone,I use S12ZVML32 for oil pump,How to do floating point operation in Q format,

   I use MC9S12ZVM_AMMCLIB  ,

   What functions should be used for multiplication and division of tfrac16 format?

1 Solution
852 Views
pachamatej
NXP Employee
NXP Employee

Hi,

I'm not sure if I'm getting your point correctly, but here is what you can do:

  • Use tFrac16 type to handle your data. Please remember that at any point, the value should fit within -1.0 and 1.0 range (internally stored as Word16 -32768 to 32767).
  • Check out the library documentation - User Guide (available in the install folder) or get the library installer from Automotive Math and Motor Control Library Set | NXP 
  • Use MLIB_Mul_F16 for multiplication and MLIB_DivSat_F16 for division. You can also use another variants of these functions (see the User Guide) - please follow the examples in the User Guide.

If you are referring to the IEEE754 floating point operation, these are not supported by the AMMCLib for S12ZVM (see the User Guide, chapter 1.2). All "floating point" operations on S12ZVM are done in normalized format and represented by tFrac16 or tFrac32. More details are available in the User Guide.

Best regards,

Matej

View solution in original post

1 Reply
853 Views
pachamatej
NXP Employee
NXP Employee

Hi,

I'm not sure if I'm getting your point correctly, but here is what you can do:

  • Use tFrac16 type to handle your data. Please remember that at any point, the value should fit within -1.0 and 1.0 range (internally stored as Word16 -32768 to 32767).
  • Check out the library documentation - User Guide (available in the install folder) or get the library installer from Automotive Math and Motor Control Library Set | NXP 
  • Use MLIB_Mul_F16 for multiplication and MLIB_DivSat_F16 for division. You can also use another variants of these functions (see the User Guide) - please follow the examples in the User Guide.

If you are referring to the IEEE754 floating point operation, these are not supported by the AMMCLib for S12ZVM (see the User Guide, chapter 1.2). All "floating point" operations on S12ZVM are done in normalized format and represented by tFrac16 or tFrac32. More details are available in the User Guide.

Best regards,

Matej