Wan Zulhelmi Wan Ahmad Kamar wrote: > Anybody has any idea how to implement delay for PIC18f. My friend > taught me a way to do it which is with NOP for delay but then that > would be redundant. It was something about 4MHz/4 = 1 MHz per > instruction == 1us. It's through counting instruction cycle. For short delays of a few instructions, I use the WAITNOP macro in STD.INS.ASPIC at http://www.embedinc.com/pic. You pass it the number of cycles to waste, and it uses GOTO or BRA instructions as 2 cycles NOPs when possible. Or course you have to make sure interrupts are off unless it's OK for the delay to take a lot longer sometimes. For long delays, don't use delays at all. Set up a periodic timer interrupt and trigger functions on this timer clock tick, or multiples of the clock tick. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com _______________________________________________ http://www.piclist.com View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist