发 帖  
【四旋翼飞行器】76小时吃透四轴算法!史上最强软硬结合实战项目,👉戳此立抢👈
[问答] 如何在硬件上找到dsPIC33EV中的浮点执行时间
4686 编译器 MPLAB
分享
HALO,我有8MHz晶体的DSIC33 EV,XC16编译器和MPLAB X。请让我知道如何在硬件上找到浮点执行时间。请编写一个小例子代码(//main main),可以帮助。

以上来自于百度翻译


      以下为原文

    Hallo,
I have dsPIC33EV with 8Mhz crystal, XC16 compiler With MPLAB X.
Please let me know how to find out floating point execution time on the hardware. Please write a small example code(//void main) which can help.
0
2019-1-28 11:15:07   评论 分享淘帖 邀请回答
19个回答
创建一个定时器,在你要测量的单元中“滴答”,启动它,执行乘法,停止计时器并查看它已经做了多少个记号。当然,这将取决于许多因素,比如使用哪个库,数字是单精度还是双精度,中断。如果定时对你来说至关重要,那么最好使用定点数。实际代码留给读者作为练习。苏珊

以上来自于百度翻译


      以下为原文

    Create a timer that 'ticks' in the unit you want to measure, start it, perform the multiply, stop the timer and see how many ticks it has made.
Of course this will vary depending on a number of factors such as which library is being used, whether the numbers are single or double precision, interrupt sources etc.
If timing is critical to you, then it is probably best to use fixed point numbers.
The actual code is left as an exercise for the reader....
Susan
2019-1-28 11:24:37 评论 举报
相乘。乘法比除法快至少18。乘法可以在1个单指令中完成。除法必须重复18次。也可以在1个指令中乘以除法。(2 ^ 15)*0.33作为一个分数,当32位时需要写额外的代码。尽量把数学保持为16位乘法。如果你想要速度。

以上来自于百度翻译


      以下为原文

    Depends.
 
Multiply is faster than divide by at least 18.
A multiply can be done in 1 single instruction.
Divide has to be repeated 18 times.
 
You can also divide by multiplying in 1 instruction.
(2^15)*0.33 as a fraction
 
You need to write extra code when it is 32bit.
Try to keep maths to 16bit multiplication if you want speed.
2019-1-28 11:31:55 评论 举报
@ 40MHz的FCY 25NS乘以ASM。

以上来自于百度翻译


      以下为原文

    @40Mhz fcy 25ns for multiply if using asm.
 
2019-1-28 11:43:23 评论 举报
在电脑屏幕上,如何停止计时器后的计时器数量?我在每微秒滴答滴答地计时。

以上来自于百度翻译


      以下为原文

   


How can i see the number of timer ticks after stopping the timer, on my computer screen? I am ticking the timer in every microsecond.
2019-1-28 12:02:47 评论 举报
如何调试?您是否有与PC机的串行连接,或者您在调试模式下使用PK3还是ICD3?如果在调试器中,只需将计数读入变量,然后使用调试器检查变量。

以上来自于百度翻译


      以下为原文

    How are you debugging?
Do you have a serial connection to the PC, or are you in debug mode with a PK3 or ICD3?
If it's in the debugger, just read the count into a variable, then inspect the variable with the debugger.
2019-1-28 12:14:04 评论 举报
微秒分辨率可能返回零。

以上来自于百度翻译


      以下为原文

    Microseconds resolution would probably return zero.
2019-1-28 12:28:14 评论 举报
当打开计时器时,TMRX寄存器(S)将开始递增。当您再次关闭计时器时,递增将停止。因此,查看TMRX寄存器。如果使用调试器,则可以查看“监视”窗口中的寄存器。否则,可以将二进制值转换为字符串,并将字符串发送到UART。还有很多其他的选择取决于您的环境。还请注意,提供的信息GOLT2105是指基于整数的硬件乘法(并且涉及到使用固定值的注释)。如果使用编译器的浮点库函数,那么时间会长得多。苏珊

以上来自于百度翻译


      以下为原文

    When you turn on the timer, the TMRx register(s) will start incrementing. That incrementing will stop when you turn the timer off again. Therefore look at the TMRx register(s).
If you are using a debugger, then you can look at the registers in the 'watch' window. Otherwise, you can convert the binary value to a string and send the string to a UART. There are lots of other options that depend on your environment.
Also note that the information Gort2105 provided refers to the hardware multiply which is integer based (and relates to may comment about using fixed point values). If you use the floating point library functions of the compiler, then the times will be much longer.
Susan
2019-1-28 12:42:45 评论 举报
以上来自于百度翻译


      以下为原文

   
2019-1-28 12:57:03 评论 举报
我用这个CAN LIN启动套件与DSPIC33 EV MCU和板上调试器。我现在没有任何UART的安装。我怀疑如果我在调试器中检查,它将测试调试器MCU(PIC24)中的代码而不是在DSPIC33 EV MCU……

以上来自于百度翻译


      以下为原文

    I use this CAN LIN starter kit with dsPIC33EV MCU and On board debugger. I donot have any setup for UART now.
 
I suspect that if i check in debugger it will test the code in debugger MCU(PIC24) not in dsPIC33EV mcu....! 
2019-1-28 13:15:09 评论 举报
你错了。只是管理界面。

以上来自于百度翻译


      以下为原文

   
You would be wrong. It's just managing the interface.
2019-1-28 13:24:06 评论 举报
不,当你触发断点时,你的代码停止,处理器跳转到调试内核代码,它不会改变任何硬件SFRs(或者它对你来说是透明的)。我还说你在你尝试读取值之前停止定时器*。当计时器停止时,无论处理器在做什么,它都不会增加。通过作出这样的评论,我必须问——为什么要知道操作需要多长时间?你试图解决的实际问题是什么让你认为你需要知道浮点乘法需要多长时间?苏珊

以上来自于百度翻译


      以下为原文

    No - when you trigger a breakpoint, your code stops and the processor jumps to the debugging kernel code which does not alter any of the hardware SFRs (or it does so transparently as far as you are concerned).
Also I said that you stop the timer *before* you try to read the value. As the timer is stopped, it will not increment no matter what else the processor is doing.
By making this sort of comment, I have to ask - why do you want to know how long the operations take? What is the actual problem you are trying to solve that makes you think you need to knwo how long a floating point multiply takes?
Susan
2019-1-28 13:37:03 评论 举报
亲爱的各位,我想到了保持C4(LeD1)PIN低,然后执行浮点运算90000000次,然后再使C4(LeD1)高等。(LeD1闪烁得很快,并且看起来像连续发光)当我检查示波器(TEKTRONIX示波器)时,我发现非常平滑。波形(时间尺度在纳秒)。有没有人能帮助我怎样用示波器检查上述方法所需要的90000000次操作所需的时间。

以上来自于百度翻译


      以下为原文

    int main()
{
    OSC_config();
    GPIO_init();

    while(1)
    {
        LED1=1;// LATC4 high
        int c=0;float d=0.0f;
        for(c=0;c<90000000;c++)
        {
            d=d+pi;
        }
        d=0;
        LED1=0;//LATC4 low
    }
}
 
Dear all, I had the idea of Keeping C4(LED1) pin low , then executing the floating point operation for 90000000 times and then making C4(LED1) high again and so on.(LED1 blinks very fast and seems like glowing continously)
When i checked in the oscilloscope(Tektronix oscilloscope) i find very smooth wave form(time scale in nanoseconds).
 
can any one help me how can i check the time needed for 90000000 operation by the above method with the help of oscilloscope.
2019-1-28 13:46:03 评论 举报
“C”不会在PIC33上计算这么多,因为它是一个int使用一个长。

以上来自于百度翻译


      以下为原文

    "c" won't count this much, on a PIC33 - being it an int
 
Try using a long.
2019-1-28 13:54:38 评论 举报
也使D挥发。LeD1=1;而ReD1=0;不做任何事情,因此被优化了。

以上来自于百度翻译


      以下为原文

    Also make d volatile. Everything between LED1=1; and LED1=0; does nothing, so is optimised away.
2019-1-28 14:12:03 评论 举报
唉,即使我做得很长,也没有什么不同。ANSUHEHUUGAUACAHACA6/AAAC/VA7/V7/ 7 +/VW8PDF982NJBM5UBR0DH99PTKYQXXL5FXMSXCXG0GTLQNJYD3D3Z2E6UULVYLY9BW1TUVFSKPKQ+PJ7X19D+FN6AMQQTK5NMTEWJOPPOKQGXTERJYY2MMDWDHR1PT08V示波器输出是平滑的波形线(在纳秒范围内)。[图像]数据:图像/PNG;BASE64,IVBWW0KGGOAAAA:FRUyMjL2XLVgAAAELklEQVR4nO3b6XaqMBQFYGWQUQFlUlG0Dn3/N7zWdt0aSJAkB1lt9/e3kM1JKYQknUwAAAAAAAAAAABgEKbtGoYRGUboOn8r3Pv5ldtGtUynrDIJ/JfUYxvzUcMX7+OF03S7U79Nha7Jyhrk6vuEHwYPX3aEb0asXKbbnaoUN/TlUnsDVbEdMzx4Hp4PFk7W7dHuaUOflj59GdFxzPBRK6cK94KeDd2lEWkVPyh8vzLHC++q3JRq6UO8IivD3I4YPqmkw+nuILJutybRSbapm3JNU8dKIZssPLqOGU7W7c5FcPQpnZX5bBaLWtsQPFMc0ZvgK3w/ZLglCr8+qTzRz6bt9vZ4Nk0Kw7G8z2NNz7JX2zdOZx5s3ToiziWmSR3ewiff4QUvPNb+W+CFvydF2Kz83D5sP0i4erdbbNfMXf5XiGMkrdYKvTpaDcZzXxC+aofXeuGLVtdUwvDNCyrX6nb//8/SqvsPy23WstAow5uxbaVBd/i6WYtOuNUIj6vuWRDSyq3Gh6B0t7cfAl9H5D0+e8yarT1Tfic57AOqV3jEzkDlqtlq4e9U4Sf5cKbbOc8f72NglvV9vhtMP5ZSV//NZgaDWd/Xasi85neKN5AzVQpnKz+qZU9sNly+20Pej/1p6UpcBDMcPivNHrrMbaAcHivNQPuP4TOZoQkzComVKmfCVSoXfJhKjrBMZiygMO1UPJ4fyJ3rJZrhzFyC5LjEI61cMvze7Uv5TD7mi3wuebKXP5x8lv800QvPHk6+jhm+VwlXfXdwWIfHX4PU7Vg/dkKmEu48vhFPY4ZfXxzuUs7RekfmenrfUT4zJlCc6DAVw0NmPL1RC/dKinCKKR5t7PzUW683c2NVSbETm7/DnuGrcpjwXiOJRrjsI3ggjXXutH4yRLOb6wJbuvBYOlxngqVZefHKcFKtpZpdLRrlm+tg1jya+4GjFS54U9zCm3tiNMNbK2SXQibc0Aon5Tev7XZHLovmXKMdVll7ZSXV3VXECd9zwg1eeKkbHrbD41t4o1l+5TOdcJN00fnGE2waOl8Wm/nNZnkULItV+uGmYNPQ9Tucf4Dsp6hM5YddMnzltEKVZdPpUXuh6s4QLih22f2CcFLyOyemB7qtE/LhV7IXkULlZ8JNI5Q8uR0ohNtPJrJbiG7DZspwU67yPe3WLVJm3Rp0iVz0hoLc8NZYVyQnD58UY4bTWreXttv222E2t/cLD35hODF33rkvOS+GfJO73Zui8+2Q4evuyrNBw4l54TZrP1lOx2UhszL2M8MDXni5rF8QTs5y/KgIqsVikQTbIlpbA/03Qkd4cA8PisgdIfx/5a7zynAAAIA/jXryGwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAqPwDmNpGS7rB4rcAAAAASUVORK5CYII=[/image]I was expecting当ReD1的方波从高到低变化时,等等。:(

以上来自于百度翻译


      以下为原文

   
Yah even if i make it long there is no difference. Oscilloscope output is smooth wavey line(in nanosecond range).[image]data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcIAAABwCAMAAAC6s4C9AAAAeFBMVEX///8AAAC/v7/7+/vw8PDf3982Njbm5ubR0dH09PTKysqXl5fExMSJiYlxcXG0tLQnJyd3d3dn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0Aon5Tev7XZHLovmXKMdVll7ZSXV3VXECd9zwg1eeKkbHrbD41t4o1l+5TOdcJN00fnGE2waOl8Wm/nNZnkULItV+uGmYNPQ9Tucf4Dsp6hM5YddMnzltEKVZdPpUXuh6s4QLih22f2CcFLyOyemB7qtE/LhV7IXkULlZ8JNI5Q8uR0ohNtPJrJbiG7DZspwU67yPe3WLVJm3Rp0iVz0hoLc8NZYVyQnD58UY4bTWreXttv222E2t/cLD35hODF33rkvOS+GfJO73Zui8+2Q4evuyrNBw4l54TZrP1lOx2UhszL2M8MDXni5rF8QTs5y/KgIqsVikQTbIlpbA/03Qkd4cA8PisgdIfx/5a7zynAAAIA/jXryGwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAqPwDmNpGS7rB4rcAAAAASUVORK5CYII=[/image]
 
I was expecting a square wave as LED1 changes from high to low and so on. :(
2019-1-28 14:30:37 评论 举报
也像Simon建议的那样,你不能粘贴像这样的图像…

以上来自于百度翻译


      以下为原文

    Do also as Simong suggested
 
Note that you can't paste images like that...
2019-1-28 14:36:45 评论 举报
LeD1^=1和一个延迟,删除另一个LeD1= 0。有更好的方法得到延迟。是否设置TISISC4为零并关闭该端口的模拟?你的延迟是什么都不做,它可能是一分钟,它将关闭纳秒。

以上来自于百度翻译


      以下为原文

     LED1^=1 and a delay, remove the other led1=0.
 
There are better ways to get a delay.
 
Did you set trisc4 to zero and turn off analogue for that port?
 
The delay you have is doing nothing, it could be for a minute, it will be off for nanoseconds.
repeat<>
led1^=1
hold time
<>
 
2019-1-28 14:56:43 评论 举报
在这里我不使用和延迟。我只想知道做90000000个浮点运算需要多少时间。是的,我已经正确地设置了LED(TIS和LAT)。

以上来自于百度翻译


      以下为原文

   
Here I am not using and delay. I just want to know how much time it requires to to do the 90000000 floating point operations.
 
Yes i have set the LED(TRIS and LAT) properly.
2019-1-28 15:08:53 评论 举报
首先,任何“int”小于90000000,所以循环应该继续下去。然后“d= d+pi;”不会产生任何影响,即使有效果,它也会在末尾被“d=0”破坏。因此,编译器可以删除所有这些东西。创建一个函数:从某处调用它。用你的范围测量脉冲宽度。

以上来自于百度翻译


      以下为原文

    First of all, any "int" is less than 90000000, so you loop should go on forever.
 
Then "d = d + pi;" do not produce any effect, and even if there was an effect, it is all destroyed with "d = 0" at the end. Therefore, the compiler can remove all this stuff.
 
Create a function:
 
 double add_pi(double d) {
  LED1 = 1;
  d = d + pi;
  LED1 = 0;
  return d;
}
 
call it from somewhere. Measure the pulse width with your scope.
 
 
2019-1-28 15:28:05 评论 举报
只有小组成员才能发言,加入小组>>
22个成员聚集在这个小组 加入小组

创建小组步骤

关闭

站长推荐 上一条 /8 下一条

快速回复 返回顶部 返回列表