I doesn't understand how this is happening...when I calculated theoretically, I got just 11161 instruction cycles...but in a website it is given as 2764795 cycles. also, I want to know how the no of instruction cycles vary with respect to delay... Plz do explain somebody..or suggest me some websites so that I will learn from that..I did google for this..But couldn't find the relevant explanation at all..am badly stuck up with this for the past few days...
This is a repeat of another thread by the same poster.
Each instruction takes a set number of clock cycles to complete. The delay is simply the total of all the times each instruction takes before returning back to the program that called it. Basically it wastes time by running loops of instructions until a condition is met that makes it return. The number of clock cycles and hence the time to complete each instruction is clearly stated in the data sheet.
Copy the code into MPLAB or MPLABX and set the watch window to show the values in d1, d2 and d3. Step through the program taking particular note of maximum values each of them reaches and PLEASE get rid of those '$+' instructions. They will come back to haunt you, I promise!