Should we add the " #define MQXCFG_ENABLE_DSP 1" in user_config.h and add(modify) "#define PSP_HAS_FPU 1" in kinetis.h ?
when we do use hard fpu.
Kevin,
for definition macros, please visit sites Freescale MQX™ RTOS for Kinetis SDK (BE|Freescale
and download SDK User´s Guide for Kinetis, MQX RTOS.
In the document you have definition of macro MQXCFG_ENABLE_FP (e.g.) on page 146.
Exactly
MQXCFG_ENABLE_FP
Default value depends on the MQXCFG_MEM_COPY_NEON. If
MQXCFG_MEM_COPY_NEON is set, default value is 1. Otherwise, default value is
0.
If it is set, enables FPU support in MQX RTOS. Scheduler stores and restores the FPU
context and provides API for float point support in tasks and interrupts.
hi,iva,
in my project,the K60F120 is used,in MQX ,i have add some define in the user_conf.h.
#define MQXCFG_ENABLE_FP 1
#define MQX_INCLUDE_FLOATING_POINT_IO 1
#define MQXCFG_ENABLE_DSP 1
and the PSP_HAS_FPU is defined in kinetis.h defaultly.
based this MQX config, i do some test for the fpu function.the code is :
_time_get (&time_rtc); | |||
printf("unsigned calculate starrting:the second is:%d,the ms is:%d \n",time_rtc.SECONDS,time_rtc.MILLISECONDS); | |||
for(i=0;i<CAL_TIMES;i++) | |||
{ | |||
result1 = oper1*oper2; | |||
result2 = oper3/result1; | |||
} | |||
_time_get (&time_rtc); | |||
printf("unsigned calculate ending:the second is:%d,the ms is:%d \n",time_rtc.SECONDS,time_rtc.MILLISECONDS); | ; | ||
where the CAL_TIMES is 100000; the oper data is unsigned int or float defined in the test program
in the MQX_template_list,i define the task between MQX_AUTO_START_TASK|MQX_FLOATING_POINT_TASK|MQX_DSP_TASK and MQX_AUTO_START_TASK,
in the two different tast set, result is almost same,the time gap is about 20ms.
now my question is :
1,is my test program can call the FPU to work?if not,how to change it?
2,in my test,the FPU is working? if it is working,it have no usage for float calculate?
Hi qin chenghu,
so, if is FPU activated is decided according to settings in the compiler.
If FPU is working you recognize according to disassembling the code and look at the special instructions for the FPU.
Through the macros is FPU switch on and there is also switch on saving FPU context with task switching.
DSP macros should have any effect for ColdFire but for Kinetis not very.
Best Regards,
Iva
Dear qin chenghu,
please, can you attach your whole project?
It looks you have not correctly set FPU.
I will test it on my side.
Best Regards,
Iva
Thank you Iva, but look into the code of mqx, when the code to check if the FPU register should be saved, it to check PSP_HAS_FPU macro too,
there must be both true for PSP_HAS_FPU and MQXCFG_ENABLE_FPU macro , but , in the kinetis.h file , no PSP_HAS_FPU define for K64F mcu,
it goes to default value "0", so , the FPU register never be saved .
Hi Kevin.
Have you solved your problem with FPU?
Best Regards,
Iva
Yes,
try to rewrite the kinetis.h,
go to row 240 and change the value.
#define PSP_HAS_FPU 1
You can use as temporary workaround. It should be fixed in next release.
Hi Kevin.
The macro #define MQXCFG_ENABLE_DSP you can add. It should be set in user_config.h.
Secondly you mentioned macro #define PSP_HAS_FPU, try to use macro MQXCFG_ENABLE_FP. If the macro is "1", shedular saves FPU registers when task switching.
Iva