can anyone explain ,what is the Exact use asm("nop") function.
It puts a "NOP" (No operation - effectively a 1 cycle delay) into the sequence of the code that is generated. At 1MHz for example a NOP takes 1us to execute so it could be used for a 1us delay. Another use sometimes is simply to put a recognisable opcode into the generated code simply to give you somewhere to put a breakpoint.
please don't use an old thread for this.
[I've now split this to be separate and will PM OP - Cliff]
This is my snippet,i have open any board,
printf("ENTER THE BOARD TO OPEN [1 - %d] : ", usCards)
can anyone explain use of format-specifier %hu
Certainly, go to a browser, choose a search engine such as Google, Bing or similar and type in "scanf %25hu". Then click on the links suggested.
The format specifiers for printf() and scanf() are virtually identical. You use 'd' for signed int, 'u' for unsigned int and you add 'h' as a prefix to say "half" - that is "short" (just as you might use 'l' to say "long" as in %ld). As it happens on an AVR both "unsigned short" and "unsigned int" are both 16 bits so it makes little difference whether you use "%hu" or just "%u" but if you took the code to a machine with 32 bit int's you would notice a difference. A %hu (or just %u) on an AVR will accept 0..65535.
PS I'm guessing the thread title I made for this split thread "use of asm("nop")" was not general enough and it should just have been something like "computers - everything you ever wanted to know but were too afraid to ask"? ;-)
© 2019 Microchip Technology Inc.