__NOP is not work?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

__NOP is not work?

7,890 Views
jakewoo
Contributor I

143635_143635.jpgQQ截图20160309093845.jpg

 

Hi,

     Just like pic.

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

Labels (1)
0 Kudos
6 Replies

4,832 Views
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 Kudos

6,345 Views
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 Kudos

6,345 Views
jakewoo
Contributor I

QQ截图20160309095558.jpg

I found __NOP, it means no use for delay?

0 Kudos

6,345 Views
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 Kudos

6,345 Views
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 Kudos

6,345 Views
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 Kudos