I am a bit familiar with assembly language and i know that the 'nop' instruction is basically used to skip an instruction cycle. What I don't know however is what the 'asm("nop")' instuction does. I tried to compile some code which included this instruction (using Keil IDE) but the compiler returns an error which i can't make sense of. The error message reads: " 'asm' requires ANSI-style prototype".
Thanks, this solved all my problems. Using _NOP_() solves everything. The code (which is example code for the CC2430 downloaded from a TI page) also supports multiple compilers (Keil, IAR e.t.c) so I think I should be fine from hereon.
To add to Esy's comments, the asm intrinsic operator is not part of ANSI C. In fact, the C standard never includes this as a keyword in its documentation. It does describe an asm styled operator which can be supplied by an implementation but it does not define it. Hence, why _asm_ is used by keil. Interestingly enough, the C++ standard does describe the asm operator as a keyword and also defines it's prototype. Because of this, many C compilers use the same prototype for coding in C as it works well when combining the two compilers into one. However, the Keil compiler is a C only compiler. It cannot compile even the most basic C++ constructs and thus it has no dependence on the C++ asm keyword.
One additional note. Most assemblers assume any line of code with non-white space characters in the first column are going to be labels. Therefore in most asm statements which are not assembler directives of some sort, there is always at least one space in front of the assembler instruction as in " nop" because "nop" will produce syntax errors in the assembler as it can become a duplicated label.
One may wish to delay processing by a known amount of cycles as it can be required for certain interactions with the hardware. An example might be to write a bit-banged serial interface where higher data rates preclude the option of using an interrupt driven context as the ISR overhead is longer than the required timing. Another option I use quite frequently is to provide a statement which does nothing but cannot be optimized away so I always have a place for a break point in a known position in code. Yet another can be to simply align certain code instructions to specific addresses. There are many more reasons but this should give you an idea.
c80f0f1006