• slider image 71
  • slider image 72
  • slider image 73

Browsing this Thread:   1 Anonymous Users

ATSAME54P20A--Hardwware FPU use?

在『MPLAB XC32 C/C++ Compiler User’s Guide for PIC32C/SAM MCUs』
For the Cortex-M based devices, such as the MEC17, CEC17, and SAM families, XC32
defaults to using the hardware Floating-Point Unit (FPU) where available. For cases
where want a specific FPU calling convention, you can specify the following
command-line options to the xc32-gcc compilation driver at both compile and link time:
• -mfloat-abi=soft -- Specifying 'soft' causes XC32 to generate output containing
library calls for floating-point operations. This setting is the default for devices that
do not feature a hardware FPU.
• -mfloat-abi=softfp -- Specifying 'softfp' allows the generation of code using hardware floating-point instructions, but still uses the soft-float calling conventions
• -mfloat-abi=hard -- Specifying 'hard' allows generation of floating-point instructions and uses FPU-specific calling conventions. This setting is the default for
devices that feature a hardware FPU.
由這段內容得知ATSAME54P20A已有hardwware FPU ,所以是否就不需要經由設定『XC32-gcc』的『General』,就可以進行單精度福點數運算?

請問使用以下方式是否就可以確定已正在使用ATSAME54P20A的hardwware FPU進行浮點數運算,或者有其他更好的方式可以證明?

float a = 0;
float b = 3;
double x = 0;
double y = 3;

int main(void)
x = 125 / y;
a = 125 / b;
printf("double value X = %10f\r\n",x);
printf("floating value a = %10f\r\n",a);

double value X = 41.666667

floating value a = 41.666668

另外,是否需要include 『float.h』?


發表於: 1/15 10:02
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部

Re: ATSAME54P20A--Hardwware FPU use?

如果是使用內建FPU系列的ARM core MCU時(SAMD5x/E5x,SAMV7/E7/S7), 則Harmony會自動在ResetHandler中啟用硬體FPU加速, 你可以在startup_xc32.c中找到 FPU_Enable(void) 這個function, 而這個Function會在Reset_Handler(void)中被呼叫, 前提是Compiler built option要有這個 -mfloat-abi=hard

經測試, XC32 Compiler會自動因為Core 是CM7 or CM4F 而自動啟動FPU, 無須添加-mfloat-abi=hard

發表於: 1/20 15:21

Edited by Libra on 2020年01月20日 16:01:54
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部

You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.