我在为DSPIC33 EP265MU806和PIC24FJ256GB106微处理器编译的通用定时器例程。因此,我开始在两种情况下测试计时器的结果,这两种情况下都是用XC16 v1.26编译器编译的。锿。因此,为了测试我启动定时器,并立即驱动一个输出引脚高(端口引脚3在两个uC)现在所有过期功能做的是翻转位“LATEbits.LATE3=~LATEbits.LATE3”,这一切都完美地工作在dsPIC33上,我用连接到引脚E3的范围检查了我的定时器。输出是一个简单的脉冲,这对PIC24FJ256GB106不起作用!我得到了我的到期函数调用,并切换引脚E3,但它立即切换。因此,我能够看到计时脉冲的结束,但引脚立即被驱动。我已经看过定时器代码,中断代码,没有发现任何问题,所以我决定编译器会产生垃圾。我试图查看调试输出,但是即使启用了调试输出,编译器实际上也不会生成任何调试输出。在MPLABX的Project属性中,调试似乎是一个很好的复选框。这是一个很棒的复选框。所以无论如何没有调试输出来查看生成的程序集,我决定从优化级别0到1。你知道什么能治愈这个问题,所以XC16显然是不可信的。也许我对优化的理解不是芯片的理解。
以上来自于百度翻译
以下为原文
I'm working on general
timer routines compiled for both the dsPIC33EP265MU806 and the PIC24FJ256GB106 micros. So I started to test the results of my timers on both, in both cases compiled with the XC16 v1.26 compiler.
I should mention how I'm testing my timers: My timers are asynchronous so I start the Timer 1 and the ISR calls an expiry function passed into the timer creation function, when the timer expires. So to test I start the timer and immediately drive an output pin high (PORTE Pin 3 in both uC) now all the expiry function does is flip that bit "LATEbits.LATE3 = ~LATEbits.LATE3"
This all works perfectly on the dsPIC33 and I checked my timers with the scope connected to Pin E3. Output was a simple pulse.
This did NOT work on the PIC24FJ256GB106! I was getting my expiry function called and toggled the Pin E3 but it immediately toggled again. So I was able to see the end of the timing pulse but the pin being driven high immediately. So I've been through timer code, Interrupt code, And found no problems so I decided that the compiler is producing rubbish. I tried to look at debug output, but even though debug output is enabled the compiler doesn't actually produce any debug output. Debug appears to be a nice check box in the project properties of MPLABx. It is a great checkbox.
So anyhow no debug output to look at the assembly produced, I decided that I'd go from optimisation level 0 up to 1. What do you know that cures the problem, so obviously XC16 is not to be trusted. Or maybe my understanding of optimisation ain't Microchip's understanding.
0