To: mas863@media.mit.edu Subject: delay code Hi, I wrote a little routine to delay for some number of milliseconds. I thought other people might want to use it. The code is below. Before calling this routine, set W to the number of milliseconds you want to delay. for instance: MOVLW 250 CALL delay_ms to delay for 250ms = 1/4 second. For times greater than 255ms you'll need to call it multiple times. I can modify it for 10ths or 100th of a second, or microseconds if people want. This routine assumes a 20MHz clock. If you have a differently valued crystal, it won't work for you. This isn't for exact timing, it is an aproximate but should be pretty close. If your program already uses memory locations 30h and 31h, just change the EQU's at the beginning. ; --- Delay Routine --- ; written by bb2 on 11/6 ; input: delay aprox. W ms ; req: for 20 MHz clock only _DELAY_PARAM EQU 0x30 _DELAY_COUNT EQU 0x31 delay_ms: MOVWF _DELAY_PARAM _delay_loop_1: MOVLW d'227' MOVWF _DELAY_COUNT _delay_loop_2: NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP DECFSZ _DELAY_COUNT GOTO _delay_loop_2 DECFSZ _DELAY_PARAM GOTO _delay_loop_1 RETURN