l.s., For delay purposes I need NOP's in an assembler macro, the code below doesn't do the trick. Thread 2267.htm doesn't help me either. A C macroloop, with e.g. DELAY(a); a = 10, slows the execution down too much. Can Anyone help me? thanks, *** #define DELAY(a) \ { \ volatile unsigned b; \ for(b = 0; b < a; b++) \ { \ } \ } #define DELAYNOP \ { \ #pragma asm \ NOP \ NOP \ NOP \ NOP \ NOP \ NOP \ NOP \ #pragma endasm \ }
***, The simplest form of a delay is:
void Delay (unsigned char Cycles) { // The following generates: // C0001: DJNZ R7,C0001 ; 1 to 256 times while (--Cycles); }
#define Delay(Cycles) { while(--Cycles); }
#include <intrins.h> void Delay (unsigned char Cycles) { do { _nop_(); _nop_(); ... } while (--Cycles); }