We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]
posted on 2015/12/09 11:23:37 AM CET
Hi.
I am using microC recently.In my code i need a small variable based delay.
ike [ Vdelay_ms ] but i need [ Vdelay_us ] can any one help me.
Thank for advance.
LOOSHA
USER Comments
posted on 2020/02/09 07:30:12 PM CET
Hello
There are for Pic18FXX
void VDelay_us(unsigned time_us){
unsigned n_cyc;
n_cyc = Clock_MHz()>>2;
n_cyc *= time_us>>4;
while (n_cyc--) {
asm nop;
asm nop;
asm nop;
}
}
for 16
void VDelay_us(unsigned time_us){ //esta funcion son delay_us pero a diferencia de la que viene en MikroC esta deja meter variables
//64Mhz time_us/=1 //Es importante elegir la opcion de acuerdo a los Mhz que trabaja el PIC
//32Mhz time_us/=2
//16Mhz time_us/=4
//8Mhz time_us/=8
//4Mhz time_us/=16
time_us /=16; //En mi caso elegi uno a 4mhz a si que selecciono 16
while(time_us--){ //crea un bucle dependiendo los microsegundos que tenga "time_us"
asm nop; //Funcion de ensamblador "No operacion"
asm nop; //Nada de esto hay que modificar si no sabemos para que es....
} //Ciero el while
}
Do you want to report abuse comment ID: 2246 in "Vdelay_us" request.