Thanks to all who replied - however, none of the routines mentioned do what I'm looking for. Olin seems to have the clearest picture of what I want. The software usec delay routine should handle a call from somewhere else in the program, loop as necessary then return. The time consumed should account for the call, the overhead, the looping, and the return. Thus, it should look like this: SoftUsecDelay(57); // C code call #asm _SoftUsecDelay: overhead loop return #endasm I want to be able to request delays anywhere from 14 to 250 usec and have the subroutine handle it automatically. Smaller delays can be handled easily. I've been going around and around with different ideas for the past few days, but it seems like I can never be accurate across the scale. I was hoping that someone had already run in to this before and had come up with a solution. With all the talent out there, I'm sure someone has and I look forward to hearing from them. Again, thanks to all who have responded so far. -----Original Message----- From: Olin Lathrop [mailto:olin_piclist@COGNIVIS.COM] Sent: Thursday, September 07, 2000 12:59 PM To: PICLIST@MITVMA.MIT.EDU Subject: Re: [PIC]: usec delay routine > Does anyone have a simple, yet accurate software usec delay routine? > I'm running 4mhz PIC16F877 and want to be able to generate a call to > SoftUsecDelay(NumberOfMicrosecondsToDelay). For short delays you can just jump into a list of NOP instructions. If you wanted to make a fancy routine, it would first subtract off all its own overhead, then use a loop for multiples of the loop time, then jump into a list of NOPs for the exact remainder. Of course interrupts would need to be off for any of this to be valid. What time ranges do you want to delay for? ***************************************************************** Olin Lathrop, embedded systems consultant in Devens Massachusetts (978) 772-3129, olin@cognivis.com, http://www.cognivis.com -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! use mailto:listserv@mitvma.mit.edu?body=SET%20PICList%20DIGEST -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu