Thanks Bob Ammerman. You help me a lot. See how I coded the program: clrf acionador ;string to AND with portB movf canal, w movwf valor ;a channel copy movwf contador ; set the counter bsf status, c rlf acionador, f ; rotates the control word decfsz contador goto $ - 2 movf sendreg, w andwf acionador, w ;verify if the channel is on low or high level btfsc status, z goto _seta ; go to the set routine comf acionador, w andwf sendreg, w ;clear bit call ser_out ;put the value on portb return _seta movf acionador, w ;set bit iorwf sendreg, w call ser_out ;put the value on portb return -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu