Makaram
Member
Hey,
Wanting to make a custom delay function for c so that I can delay using a variable rather than just using constants as __delay_us(x) only allows.
Many of you would probably have come across this issue in the past and triumphed, if so could you please point me in the right direction or perhaps link some code.
I've tried functions such as this
void ServoDelay (long delay){
while(--delay != 0);
}
with varying amounts of offsets etc to allow for the clock cycles involved in the while loop,
But surely there is a more elegant (and accurate) solution?!
Thanks
Wanting to make a custom delay function for c so that I can delay using a variable rather than just using constants as __delay_us(x) only allows.
Many of you would probably have come across this issue in the past and triumphed, if so could you please point me in the right direction or perhaps link some code.
I've tried functions such as this
void ServoDelay (long delay){
while(--delay != 0);
}
with varying amounts of offsets etc to allow for the clock cycles involved in the while loop,
But surely there is a more elegant (and accurate) solution?!
Thanks