On Mon, 9 Mar 1998 22:30:32 +0200 George Kranis writes: >How can i program the PIC16F84 to delay for 1 sec before make a RA >output equal to 1? The two operations are entirely seperate. First you make the program do nothing for 1 second. The easiest way to do this is to use a loop that decrements a RAM location until it is zero: movlw startval ;Get constant initial value movwf delayv ;Store in RAM delaylp decfsz delayv,f ;Count RAM down, skip when done goto delaylp ;Not done, loop again. This can delay up to 769 instruction cycles (using startval=0). At most PIC clock rates this isn't enough cycles to take anywhere near a second. With a 4 MHz crystal, you need to delay 1000000 instruction cycles. The solution is to nest multiple loops, using several RAM locations to keep track of them all: movlw startval movwf delayv clrf delayv1 clrf delayv2 delaylp decfsz delayv2,f goto delaylp decfsz delayv1,f goto delaylp decfsz delayv,f goto delaylp Approximately this takes (772 * 256 * startval) cycles. So for a delay of *approximately* 1 second with a 4 MHz PIC crystal, use startval = 5. If a delay of *exactly* 1 second is needed, delayv1 and maybe even delayv2 would need to be set to computed initial values other than 0. Once the delay is done, the next instruction would just be a conventional setting of the PORTA bit. If the PIC needs to do something else during the 1 second interval, then it gets much more complicated. But it is still possible. Exactly how depends on what else it needs to do. _____________________________________________________________________ You don't need to buy Internet access to use free Internet e-mail. Get completely free e-mail from Juno at http://www.juno.com Or call Juno at (800) 654-JUNO [654-5866]