I am working with a K60FN1M processor and using CW10.4. I want to make sure that I am setting up the hardware FPU correctly. I have done the following:
1 - Selected Hardware vfpv4 in the Tool Settings under project properties.
2 - Selected c9x for the Library model
3 - Included the ewl c library
4 - Explicitly enabled the FPU by setting bits 10 and 11 in SCB_CPACR
5 - Set both the ASPEN and LSPEN in SCB_FPCCR to enable the extended exception frame and the lazy stacking options
6 - Added the suffix f to all float constants.
I am using a preemptive task scheduler rather than a full RTOS.
I want to be able to use library routines such as powf(), expf(), etc. and have them only use single precision float values. Is there a specific ewl library that I should specify or certain macros that need to be defined?
Thanks,
Elizabeth
Hi,
There is no specific ewl library, you can use the system default one.
About enable the FPU, please check code for your reference:
; Enable the floating point coprocessor
#if defined (_VFPv4_)
MOVW r1,#60808 ; load CPACR
MOVT r1,#57344 ; (0xE000ED88)
LDR r0,[r1]
ORR.W r0,r0,#VFPEnable ; Enable FPU
STR r0, [r1] ; on CP10, CP11
MOV.W r0,#R2N_Enable
VMSR FPSCR, r0
#endif
Wish it helps.