[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-chat] portable no-op with AVR GCC, AVR LIbc?
From: |
Anthony Andriano |
Subject: |
Re: [avr-chat] portable no-op with AVR GCC, AVR LIbc? |
Date: |
Sun, 29 Jan 2012 18:54:46 -0700 |
I usually do this if I need a single cycle delay:
asm("nop");
Be careful if you need to do it multipe times as it will be optimized and the results may be unexpected (assuming you are using optimization).
There is also:
__builtin_avr_delay_cycles(unsigned long __n);
The compiler will delay exactly as many cycles as you provide with the argument by inserting useless, and more importantly harmless, code. I usually see something like a string of subtracts, adds, etc.
On Sun, Jan 29, 2012 at 6:23 PM, Britton Kerin
<address@hidden> wrote:
I notice the AVR Libc include/compat/ina90.h has this:
#define _NOP() do { __asm__ __volatile__ ("nop"); } while (0)
but I didn't find anything else "nop"ish. I generally don't include ina90.h.
Is there some good concise GCC/AVRLibc way to write nop that I missed?
Thanks,
Britton
_______________________________________________
AVR-chat mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/avr-chat