> I am trying to generate a delay for the 20 MHz PIC16F877 that I > am using to interface it to the LCD. I think I don't understand > how to generate the delay because I know that my hardware is > working perfectly. Can some one please tell me how to calculate > the delay in seconds for the following code. > Thank you > Sarah > > LOOPD equ 2Ah > . > . > . > > delay movlw .90 > movwf LOOPD > repeat nop > decfsz LOOPD > goto repeat > return I personally don't like busy-waits much. The timing can't be relied on when there are interrupts, and the processor is completely out to lunch during the wait. Especially when the wait is more than a few milliseconds, I prefer to set up a periodic interrupt. 1mS is often a convenient interrupt period. The interrupt routine decrements a counter if it is not already zero. The foreground code sets the counter then checks for it to become zero. Meanwhile, it can be doing other tasks, as long as it gets back to checking the wait counter fast enough. Note that you can support more than one simultaneous wait counter this way, and they can each be clocked at a separate multiple of the interrupt period. I've had projects that simultaneously used 1mS, 10mS, and 100mS wait counters, all derived from the basic 1mS interrupt. ***************************************************************** Olin Lathrop, embedded systems consultant in Devens Massachusetts (978) 772-3129, olin@embedinc.com, http://www.embedinc.com -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body