is there any way to repeat a C code N times with a macro? Also N is a macro.
For example if I have this macros:
#define N 5
#define COODE "nop\n\t"
#define REPEAT [...]
When I call repeat the preprocessor writes CODE N times, so
__asm__(REPEAT);
would became
__asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t""nop\n\t");
I have an Arduino that have to wait for an exact (and small, about 10-15) number of clock. Each "nop" (no operation) takes exactly 1 clock cycle to be executed, and it does nothing. I can't just do a cycle, because each cycle is executed in more than one operation (initialize the counter, increment the counter, check if reached end), so instead of writing manually "nop\n\t" I'd like to have a macro. This way I can also simply change N to modify the program without rewriting it.
Thank you in advance
nop
s to finish out the delay. It's more effort to write but much more compact. – Flewsnop
s to save typing, but I don't think theres a way to make a "paste this N times" macro as you've requested. – Flews#define _5(x) x ## _4(x)
where _1(x) ... _4(x) would look similar – Mcwhirter#include
a file recursively, you can cook something up... – Nobbyfor
loop or calling adelay
function? – Cardiology