Hello all. I am working on a small robot project and need to generate a pulse at 40 - 60 hz (from what I have read so far on servos) that is accurate to within .01 ms. I will be using a 16F84 and a 10.0 MHz ceramic resonator. I have done the following math... 10000000 cycle/sec * 1 instruction/4 cycles = 2500000 instructions/sec. now assuming that I do not prescale it... I also have 2500000 TMR0 Increases/sec. 2500000 TMR0 Increases/sec * 1 loop/X TMR0 Increases = 1000 loops/sec X = 2500 TMR0 Increases = 10 * 250 TMR0 increases with this in mind I wrote a simple function in PIC C (I do not assembler... I really wish I did) void delay(long int times, int cycles) { long int i; for(i = 0;i < times;i++) { TMR0 = 0; while(TMR0 < cycles); } } so to use this function I should call it like this: while(1) { servo = 1 //turn the servo bit on delay(10,250); //delay for 1 ms. servo = 0; //turn the servo bit off. delay(xxx,xxx); //where xxx,xxx is the numbers needed for a 40hz pulse) } unfortunately there is a abit of error somewhere in my method, can anyone help me track it down? I believe it has to do with the fact that I am not incorperating the amout of time it takes to execute the instructions in calling the "delay" routine, and each instruction within that routine. any help would be much appreciated as would any comments on the method I am choosing to do this. Also could anyone recommend any good PIC books to help a begginer get started with PIC Assembler? Thanks, Sam