sadandonmez Guest
|
delay_us(time) command usage |
Posted: Sat Nov 04, 2006 3:41 pm |
|
|
hi,
in my program (PIC16f877 20MHz) I want to use delay_us command with a "variable", for example;
alpha=5000;
delay_us(alpha);
but you know, CCS manual says "time - a variable 0-255 or a constant 0-65535"
so for an easy solution, i wrote a "moredelay" function like this:
void moredelay(long x)
{
int kalan, bolen,i;
kalan = x%255;
bolen = x/255;
for(i=1;i<=bolen;i++)
{
delay_us(255);
}
delay_us(kalan);
}
it works, but with additional faulty delay. for example when x=0, it waits extra 2-3ms..
could you please explain how can I solve the problem... ?? |
|