This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] Compiler/MSP432P401R:延迟实施

Guru**** 2535590 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/578661/compiler-msp432p401r-delay-implementation

部件号:MSP432P401R

工具/软件:TI C/C++编译器

空延迟(uint16_t msec){
uINT32_t i=0;
uINT32_t时间=(msec/1000)*(system_clock _速度/15);

对于(i=0;i<time;i++);
}

这是Kentec触摸屏grlib示例中使用的延迟。 我注意到我甚至没有被标记为易变。 这不应该被优化吗? 添加优化时是否需要小心? 编译器是否足够智能,可以看到“delay”一词并将其单独保留? 8^)

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    \n这不应该得到优化吗? [/引述]

    如果使用--opt_level=2或更高版本,它将得到优化。

    Keith Barkley 说:
    我注意到我甚至没有被标记为易失性。[/QUOT]

    虽然有点麻烦,但在这里标记变量I volatile是一个很好的解决方案。

    我会找到负责此代码的团队,并让他们知道问题。

    谢谢,此致,

    -George