user37799: Is it possible to redefine delay and delaymicros function with #define ?
I want to use timer2 interrupt instead of these.
Something like this:
#define delay(unisgned long ms) countMicros(uint16_t top, uint16_t storageVar)

setup(){}

loop(){
 delay();// function countMicros is called instead.
 }
void countMicros(uint16_t top, uint16_t storageVar){
//...}


user7508: Not exactly like that. You will have to manage the different sets of
parameters, i.e. convert the incoming ms into the top and
storageVar that would be appropriate for calling countMicros().
Maybe something like this:
#define delay(ms) mydelay(ms)

void mydelay(unisgned long ms) {
    uint16_t top = some expression;
    uint16_t storageVar = another expression;
    countMicros(top, storageVar);
}

where both expressions are a function of ms.
If the expressions are really simple, you could even put the whole thing
inside a single macro, as in
#define delay(ms) countMicros(some expression, another expression)


37799: <p>Is it possible to redefine delay and delaymicros function with #define ?
I want to use timer2 interrupt instead of these.</p>

<p>Something like this:</p>

<pre><code>#define delay(unisgned long ms) countMicros(uint16_t top, uint16_t storageVar)

setup(){}

loop(){
 delay();// function countMicros is called instead.
 }
void countMicros(uint16_t top, uint16_t storageVar){
//...}
</code></pre>
 7508: <p>Not exactly like that. You will have to manage the different sets of
parameters, i.e. convert the incoming <code>ms</code> into the <code>top</code> and
<code>storageVar</code> that would be appropriate for calling <code>countMicros()</code>.
Maybe something like this:</p>



<pre class="lang-c++ prettyprint-override"><code>#define delay(ms) mydelay(ms)

void mydelay(unisgned long ms) {
    uint16_t top = some expression;
    uint16_t storageVar = another expression;
    countMicros(top, storageVar);
}
</code></pre>

<p>where both expressions are a function of <code>ms</code>.</p>

<p>If the expressions are really simple, you could even put the whole thing
inside a single macro, as in</p>

<pre class="lang-c++ prettyprint-override"><code>#define delay(ms) countMicros(some expression, another expression)
</code></pre>
