__NOP is not work?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

__NOP is not work?

9,532件の閲覧回数
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,474件の閲覧回数
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 件の賞賛
返信

7,987件の閲覧回数
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 件の賞賛
返信

7,987件の閲覧回数
jakewoo
Contributor I

QQ截图20160309095558.jpg

I found __NOP, it means no use for delay?

0 件の賞賛
返信

7,987件の閲覧回数
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 件の賞賛
返信

7,987件の閲覧回数
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 件の賞賛
返信

7,987件の閲覧回数
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 件の賞賛
返信