XMC4400 floating point operation

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User11506
Level 2
Level 2
Hi everybody, 🙂

I am writing this post because I am about to start a project where I will be using the XMC4400 and

I have some doubts regarding the execution of floating point mathematic operations and the enabling of the floating poit unit.

The idea is simple, perform all kinds off mathematical operations using floating point variables.

I am using DAVE 4.3.2, and I have created a project from scratch without using APPs.

so far I have been implementing just fixed point opeerations using integers as variables but now I want to use floating point variables.

I was reading a bit the user manual and I found the following :

The FPU is disabled from reset. You must enable it before you can use any floating-point
instructions. The Example shows an example code sequence for enabling the FPU in
both privileged and user modes. The processor must be in privileged mode to read from
and write to the CPACR.


Does this mean that I have to write some extra code in order to enable the FPU? If yes, where exacli? and, which code? I tried adding the code present in the manual but I get some arrors when compiling.

Is there a special library which I have to use for fast floating point operations? (as for example the xmc_math wich makes uses of the CORDIC unit in the XMC1000 series)


Thank you very much for your time! 😄
0 Likes
2 Replies
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi,

The FPU is enabled in the system_XMC4xxx.c in SystemCoreSetup() function with following code.

#if ((__FPU_PRESENT == 1) && (__FPU_USED == 1))
SCB->CPACR |= ((3UL << 10*2) | /* set CP10 Full Access */
(3UL << 11*2) ); /* set CP11 Full Access */
#else
SCB->CPACR = 0;
#endif

The macro __FPU_PRESENT is defined and set to 1 in the XMC4xxx.h, indicating that the XMC4xxx CortexM4 implementation includes an FPU (FPU is optional in CortexM4 devices)
A second macro __FPU_USED is defined in core_cm4.h depending on whether the application is compiled using FPU support.
If you select full software floating point (-mfloat-abi=soft) then __FPU_USED will be defined as 0, otherwise (-mfloat-abi=softfp or –mfloat-abi=hard) in__FPU_USED will be set to 1.

The CMSIS DSP library make use of the FPU. The CMSIS DSP is available as an APP or as part of the XMCLib.

Best regards,
Jesus
0 Likes
User11506
Level 2
Level 2
Thanks a lot Jesus, it really helped! 🙂
0 Likes