K20 FLOATING COPROCESSOR

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

K20 FLOATING COPROCESSOR

634 Views
kooroshhajiani
Contributor III

Hello,

I'm not certain if K20 has a floating coprocessor .

I've the following line in the code:

ad_result2_word=(float)DAC2_prev*((float)result_1/(float)result_2);

where:

ad_result2_word,DAC2_prev are uint32_t and result_1,result_2 are uint16_t

when I single step through the code I can verify the result as correct however when I let it run for awhile and stop it the result are bogus values.

I'm using KDS for the project .

I'M NOT SURE IF I'M DOING THIS MULTIPICATION CORRECTLY OR IF KDS IS USING SOME FLOATING LIBRARY OR EVEN IF K20 HAS A FPU.

Any ideas?

Thanks,

Koorosh Hajiani

248-778-6396

0 Kudos
2 Replies

406 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

in addition, only the part number with "F" has floating point module. for example K22F can support FP but K20 can't.

with K22F, we can set floating support as

pastedImage_0.png


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

406 Views
egoodii
Senior Contributor III
  1. The part has to have a 'K20F' start to the P/N to be a 'single precision float hardware' part
  2. The 'floating instruction decode' has to be enabled in the system control register: 0xE000ED88 CPACR RW - Coprocessor Access Control Register
  3. The compiler has to be 'told' you are using a 'float point capable' part so that it will insert float-instructions where it can, rather than library-routine access.

BUT 'ideally' the library-routines and the hardware would *ALWAYS* return the same values, the only DIFFERENCE should be the execution time + code size for the library (and of course the actual instruction stream, which you should look at to SEE the 'float' instructions to 'know what you get').  That is to say, you should look elsewhere for 'bogus values' coming out.

0 Kudos