__NOP is not work?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

__NOP is not work?

9,722 次查看
jakewoo
Contributor I

143635_143635.jpgQQ截图20160309093845.jpg

 

Hi,

     Just like pic.

     I want to delay  1us,but it is not work. 

标签 (1)
0 项奖励
回复
6 回复数

6,664 次查看
cbabcock
Contributor I

__NOP is declared as a function, with the prototype void __NOP(void). You need to call it like "__NOP()", not just "__NOP".

0 项奖励
回复

8,177 次查看
bobpaddock
Senior Contributor III

You did not say what specific ARM part you where using.

NOP is not necessarily a time-consuming depending on the processor. The processor might remove it from the pipeline before it reaches the execution stage.  One of the barrier instructions might be more appropriate, for example:

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/CHDEBIEG.html

Also as others noted a NOP must be marked volatile, some compilers such as GCC will remove instructions that have no side-effects.  Marking the instruction volatile will make sure that it is not removed by the optimizer.

0 项奖励
回复

8,177 次查看
jakewoo
Contributor I

QQ截图20160309095558.jpg

I found __NOP, it means no use for delay?

0 项奖励
回复

8,177 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Jake,

from your code __NOP can be used for delay. can you please test to step over the __NOP, can it work normal?

if you increase the value of delay_cnt, can you see the time cost for delay_us() increased with scope?


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复

8,177 次查看
jakewoo
Contributor I

Hi,

     I try __asm("nop"),and can work.

But __NOP is not work,and jump over the __NOP.It is maybe unbelivable:smileyconfused:.

0 项奖励
回复

8,177 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Jake,

__asm("nop") is the right inline assembly syntax.

I would like to suggest you look this article on this related topic.

Extended Inline Assembly with Kinetis Design Studio

can this help you?
Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复