unsigned char myMS;
unsigned char myUS;
/*
InitDelay
MS:
4 = 4 MHz = 1000 Cycles
8 = 8 MHz = 2000 Cycles
20 = 20 MHz = 5000 Cycles
US:
I recommend inline asm or few Nop() for 1-10 us Delays
4 = 4 MHz = 1 Cycles
8 = 8 MHz = 2 Cycles
20 = 20 MHz = 5 Cycles
*/
void DelayMS(unsigned int ms){
unsigned int x;
for(x=0;x<ms;x++)
Delay1KTCYx(myMS);
}
void DelayUS(unsigned int us){
unsigned int x;
char y;
if(myUS * us < 10 ) return;
for(x=1;x<us;x++)
for(y=0;y<myUS;y++)
Delay1TCY();
}
void InitDelay(unsigned char speed){
switch(Speed){
case 4:
myUS = 0;
myMS = 1;
break;
case 8:
myUS = 2;
myMS = 2;
break;
case 20:
myUS = 5;
myMS = 5;
break;
}
}