This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

assembler macro included in C macro

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 \
}

Parents
  • 1) Use a = 9?

    2) In <intrins.h> there is an _nop_() function.

    3) The following generates a tight loop (an DJNZ instruction )

       register unsigned char i;
       i = count;
       do { --i; } while( i != 0 );
    
    
    
    

Reply
  • 1) Use a = 9?

    2) In <intrins.h> there is an _nop_() function.

    3) The following generates a tight loop (an DJNZ instruction )

       register unsigned char i;
       i = count;
       do { --i; } while( i != 0 );
    
    
    
    

Children