完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,我使用PIC32 MZ2048 EFH064,XC32 V1.42,MPLAP X3.5.1,和声2.0.2.4,如果长浮点库关闭(MnO-FLUE),将下列两个“双浮点”分开,导致错误的结果。在调试会话中,使用PICIT3.3易失性长TestLDL;易失性长双TestLD2;易失性长双TestLD3;TestLD1=100;TestLD2=30;TestLL=30;TestLD3=100/30;//OK/*A*/TestLD3=TestLD1/TestLD2;//OK/*B*/TestLD3=TestLD1/TESTLL;//WRO;NG结果(无限或其他)/*C*/TestLD3= TestLD1//(long double)TESTLL;//错误结果(无限或其他)根据XC32编译器用户指南long long是一个64位支持的数据类型。如果我使用32位长类型的TestLL都很好。如果关掉浮点库(PIC的FPU),对32位数据类型有什么限制吗?我会假设使用标准的C数学库来代替?仅仅是数学,H或不改变任何东西。只是为了背景信息,我必须把FPU关掉,因为我也使用DSP内核,而且如果使用来自LIFBQYQ31的浮点将浮点DSP系数翻译成定点TPp,那么PIC32 MZ EF类型就有一个定时问题。ES由于从FPU到DSP内核的数据传输。在这个论坛上的另一个线程,我不在这里。作为一个规避,有可能应用源文件MNO-FLUP,还是总是对所有源文件?也许有人能给这种奇怪的行为带来更多的光亮?我做错什么了吗?谢谢米迦勒
以上来自于百度翻译 以下为原文 Hi, I am using PIC32MZ2048EFH064, XC32 V1.42, MPLAP X 3.5.1 with HARMony 2.0.2.4. Doing the following divisions of 'double float' by 'long long' leads to wrong results if floating point library turned off (-mno -float). The behaviour can be reproduced with the simulator, but leads also to wrong results in debug session with Pickit3. volatile long long TestLL; volatile long double TestLD1; volatile long double TestLD2; volatile long double TestLD3; TestLD1 = 100; TestLD2 = 30; TestLL = 30; TestLD3 = 100.0 / 30.0; //ok /*a*/ TestLD3 = TestLD1 / TestLD2; //ok /*b*/ TestLD3 = TestLD1 / TestLL; //wrong result (infinity or other) /*c*/ TestLD3 = TestLD1 / (long double) TestLL; //wrong result (infinity or other) According to the XC32 compiler user's guide long long is a 64 bit supported data type. If I use 32 bit long type for TestLL all is fine. Is there any limitation to 32 bit data types if the floating point library (FPU of PIC) is turned off? I would assume that standard C Math libraries are used instead? Including math.h or not does not change anything. Just for background information, I have to turn the FPU off with -mno - float as I am using the DSP kernel as well and there is a timing issue with the PIC32MZ EF types if using _LIBQ_Q31FromFloat to translate float DSP coefficients to fixed point types because of data transfer from FPU to DSP Kernel. It is on another thread in this forum I don't have at hand here. As a circumvention, is it possible to apply -mno-float by source file or is this always for all source files at once? Maybe someone could bring a little bit more light into this strange behaviour? Am I doing something wrong? Thanks Michael |
|
相关推荐
5个回答
|
|
在MPLABX中,您应该能够按每个文件覆盖构建选项。我没有XC32的经验,但原理应该是一样的。
以上来自于百度翻译 以下为原文 In MPLABX you should be able to override build options by per file basis. I have no experience with XC32 but the principle should be the same. Attached Image(s) |
|
|
|
尼古拉,谢谢。这有助于只在需要时排除浮点库。无论如何,如果应用了-MNO浮点,编译器会选择哪些库,它们对LL和LD有64位支持吗?它可能对更多的人感兴趣,因为有些人可能需要使用FMU和DSP内核的PIC32 MZ EF类型的MNO浮动。有人知道吗?
以上来自于百度翻译 以下为原文 Nikolay, thanks. That helps to exclude float libraries only where needed. Anyway, what libraries are selected by the compiler if -mno-float is applied and do they have 64 Bit support for LL and LD?. It could be of interest to more people as some may have to use -mno-float for PIC32MZ EF types with both FPU and DSP kernel. Does anybody know? |
|
|
|
我刚刚运行了一些测试,并且在编译器选项中添加-MNO浮动不妨碍编译器在库例程中使用FPU。它确实阻止编译器生成不需要库的正常浮点数学的FPU指令。为了确认,在执行需要例程的浮点运算之前,添加以下内容:禁用硬件中的FPU,以确认FPU未被使用。在下面的代码中,我得到与LD/LL除法(无穷大)相同的结果;在运行带有或不带有-MNO浮点的测试代码时,我得到第二个LD/LL除法,因此FPU被肯定地使用。如果我排除链接器中的浮点LIBs,链接会由于浮点的使用(不奇怪)。LD/LL除法的错误结果肯定是编译器错误。你应该举出一张票,指出这条线索。也许如果杰森在场,他会发表评论。
以上来自于百度翻译 以下为原文 I have just run a few tests, and adding -mno-float to the compiler options *does not* prevent the compiler from using the FPU in library routines. It does prevent the compiler from generating FPU instructions for normal floating point math not requiring the library. Just to confirm, add the following before doing any floating point math which requires the routines. uint32_t c0_12_0=_mfc0(12,0); c0_12_0&=~(0x1<<29); _mtc0(12,0,c0_12_0); That disables the FPU in hardware, to confirm that the FPU is/isn't being used. Testing with the following code, I get the same result as you for the ld/ll divide (Infinity); volatile long double ld=100.0; volatile long long ll=30; volatile float f1=100.0f; volatile long l=30.0; volatile long double ldres=ld/ll; volatile float fres=f1/l; uint32_t c0_12_0=_mfc0(12,0); c0_12_0&=~(0x1<<29); _mtc0(12,0,c0_12_0); fres=f1/l; ldres=ld/ll; In running the test code built with or without -mno-float I then get Runtime exception @ PC address 0x9d007da0 in function: __floatdidf ( ) at /build/bamboo/xml-data/build-dir/XC32-CYXC32-JOB1/xc32-XC32-release-1_42/src48x/gcc/libgcc/libgcc2.c : 1473 for the second ld/ll divide,so the FPU is definately being used for that. If I exclude floating point libs in the linker, link fails due to the use of floating point (no surprise there). The incorrect result for the ld/ll divide is definately a compiler bug. You should raise a ticket, pointing out this thread. Perhaps if Jason is around, he would comment. |
|
|
|
嗨,谢谢你的澄清。不,它更清楚了。我已经为完蛋虫打开了00215349号罚单。米迦勒
以上来自于百度翻译 以下为原文 Hi, thanks for clarifying. No it is much clearer. I have opened ticket 00215349 for the compler bug. Michael |
|
|
|
这张票是按照设计的方式关闭的。对于每个遇到同样潜在问题的人来说,有些信息是困难的。在XC 32编译器用户指南中,对-MNO -浮点的解释显示:“MNO-FLUT:排除浮点操作的支持,减少不需要浮点支持的应用程序的代码大小”,但该语句并不完全正确。显然,它只会影响64位的支持,因为32位的运行没有任何错误,选择了-MNO-FLUT。此外,如果选择了浮点数,即使选择了-MNO-FLUT,也不会有来自编译器的警告。这只是错误的结果。这里的建议是改变2件事:1)更改文档:将语句改为“-MNO -浮点:排除对64位浮点操作的支持……”(如果这是在Microchip中的某个人确认的)2)如果M- MNO-FULL被选中:“使用警告浮动但-MNO-FLASH选择”,则更改编译器以警告浮点使用。我不认为它是编译器从编译到没有错误或警告的预期行为,并且结果代码只是PROD。错误的结果。米迦勒
以上来自于百度翻译 以下为原文 The ticket is closed as 'works as designed'. Just for everyone who runs into the same potential trouble some information. In the XC 32 compiler user's guide the explanation for -mno - float shows: 'mno-float: Exclude support for floating-point operations reducing code size for applications that do not require floating-point support.' But this statement is not fully correct. Obviously it just affects 64 bit support as 32 bit runs without any error, with -mno -float selected. In addition there is no warning from the compiler if float is used in the coding even with -mno -float selected. It is just wrong results. The suggestions would be to change 2 things here: 1) change documentation: Change the statement towards '-mno -float: Exclude support for 64 bit floating-point operations... (if this is confirmed by someone at Microchip) 2) change the compiler to warn about float usage if -mno -float is selected: 'Warning float used but -mno -float selected' I don't think that it is an expected behavior from a compiler to compile without errors or warnings and the resulting code just produces wrong results. Michael |
|
|
|
只有小组成员才能发言,加入小组>>
5183 浏览 9 评论
2005 浏览 8 评论
1932 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3178 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2229 浏览 5 评论
739浏览 1评论
626浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
510浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
637浏览 0评论
535浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-27 20:16 , Processed in 1.460928 second(s), Total 84, Slave 68 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号