Hello,
float in printf return blank. How to activate it ?
Thank you.
Hello,
float in printf return blank. How to activate it ?
Thank you.
In Keil Settings->Target->Floating Point Hardware -> Use single presecision
This will do nothiing but just set some compiler macros in core_cm4.h
#elif defined ( __ICCARM__ )
#if defined __ARMVFP__
#if (__FPU_PRESENT == 1U)
#define __FPU_USED 1U
#else
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
#define __FPU_USED 0U
#endif
#else
#define __FPU_USED 0U
#endif
This is inturn used in system_nrf52.c->SystemInit()
#if (__FPU_USED == 1)
SCB->CPACR |= (3UL << 20) | (3UL << 22);
__DSB();
__ISB();
#endif
Then your compiler will generate hardware floating point instructions and your printf shouldl work normally.
If you have MicroLib set in Settings->Target->Use MicroLIB, then i think it optimizes float instructions. I am not sure how it works here, but i suspect floating point calculations will be tricky. I never use MicroLIB when i want software float.
If you do not want to use avialable VFP hardware in nRF52(i cannot imagine why not but its your choice). Then you can add
Settings->Target->Floating Point Hardware -> Use single presecision
Settings->C/C++->Misc controls->--fpu=softvfp
Settings->Linker->Misc controls->--fpu=softvfp
In Keil Settings->Target->Floating Point Hardware -> Use single presecision
This will do nothiing but just set some compiler macros in core_cm4.h
#elif defined ( __ICCARM__ )
#if defined __ARMVFP__
#if (__FPU_PRESENT == 1U)
#define __FPU_USED 1U
#else
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
#define __FPU_USED 0U
#endif
#else
#define __FPU_USED 0U
#endif
This is inturn used in system_nrf52.c->SystemInit()
#if (__FPU_USED == 1)
SCB->CPACR |= (3UL << 20) | (3UL << 22);
__DSB();
__ISB();
#endif
Then your compiler will generate hardware floating point instructions and your printf shouldl work normally.
If you have MicroLib set in Settings->Target->Use MicroLIB, then i think it optimizes float instructions. I am not sure how it works here, but i suspect floating point calculations will be tricky. I never use MicroLIB when i want software float.
If you do not want to use avialable VFP hardware in nRF52(i cannot imagine why not but its your choice). Then you can add
Settings->Target->Floating Point Hardware -> Use single presecision
Settings->C/C++->Misc controls->--fpu=softvfp
Settings->Linker->Misc controls->--fpu=softvfp