Hi everyone! I'm trying to send a byte from a 16F84 to a 16F874 connected by two lines. For reasons i won't go into i have to do the communication protocol in software, so please don't suggest alternative hardware solutions or use of usart etc! I'm using two PIC boards to test the software, but it doesn't work as i thought. I've pasted the gist of the code i'm using: can anybody see something wrong? I am sorry for the length of the e-mail. Thanks in advance for any help! Regards, Theodore ;******* CODE FOR 16F84 -- TRANSMIT ;******* PORT/PIN MAP ; porta,rx: receive line, connects to porta,tx_m of 16F874 (Master) ; porta,tx: transmit line, connects to porta,rx_m of 16F874 bcf porta,tx ; send request to transmit (a handshake of sorts) ; active low: tx line high when idle -- clear for request call delay ; delay subroutine btfsc porta,rx ; check Master ready to receive goto $-1 movf portb,w ; the state of portb is to be transmitted movwf dataout movlw 8 ; 8 bit transmission movwf bitcount bsf porta,tx ; send start bit (high) bit_out call delay call delay ; "baud" rate rrf dataout,f btfsc status,c ; if c high, send high bit bsf porta,tx btfss status,c ; if c low, send low bcf porta,tx decfsz bitcount,f goto bit_out bcf porta,tx ; send stop bit (low) return ;******* CODE FOR 16F874 -- RECEIVE btfss porta,rx_m goto $-1 bcf porta,tx_m ; ready to receive movlw 8 ;8 bit reception movwf bitcount btfss porta,rx_m ; wait for start bit, high goto $-1 call delay ; extra delay before starting to receive byte bit_in call delay call delay btfsc porta,rx_dir bsf byte_in,7 ; register to receive byte btfss porta,rx_m bcf byte_in,7 rlf byte_in,f decfsz bitcount,f goto bit_in btfsc porta,rx_m goto $-1 ; wait for stop bit bsf porta,tx_m ; acknowledge stop bit, set line high again (high when idle) return ____________________________________________________________ Do You Yahoo!? Apojt^ste tg dyqe\m @yahoo.gr die}humsg sar sto http://www.otenet.gr -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads