Question is Regarding Floating Division S12Z Micro

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

Question is Regarding Floating Division S12Z Micro

508 Views
g_sravanreddy
Contributor I

Question is Regarding Floating Division 

ex: 0.02/0.0106 i have division requirement like mentioned Denominator  0.0106 is a constant value Numerator will be changing from 0.01 to 0.1 for 0.01 we can use MLIB_Div but for other values i have to go with normal division which will result value with round off value or no decimal points please suggest some suggestion.

0 Kudos
2 Replies

435 Views
kef2
Senior Contributor IV

Hi,

I wonder what is the problem actually?

  •  i have to go with normal division which will result value with round off value or no decimal points

Could you please clarify this?

Optimized FP division on S12Z takes up to 300 bus cycles, ~9 us at 32 MHz. Any problem with this?

As Ladislav suggested most of real life needs for division are replaceable with multiply, .. and some shifts. And shifts are very fast on S12Z, thanks for barrel shifter, which was not available in HC12/S12 CPU's which had to loop shifting by one bit position at once. QMUL instructions further help making your calculation faster, even shifts may be often eliminated, and S12Z compiler supports __qmulXX intrinsic functions to make our life easier.

Edward

0 Kudos

435 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

For example....

Sometimes i tis good to think about normalization and already use input values in „unsigned integer“ form. Simply move decimal point to right. It means multiply by constant. You have enough range for precise division if you expect max value on nominator 0.01 and constant denominator 0.0106.

Othervise, if a time is not a condition then floating point library is a solution.

Moreover, I do not know your application but also searching table (in reasonable set of nominators) could be a (fastest) solution.

Best regards,

Ladislav

0 Kudos