From: Scott Dattalo [SNIP] > Agreed. However, it would be possible to receive data with 3-cycle > resolution using a variation of the trick I posted to help solve Dwayne > (a.k.a. David) Reid's pulse measuring problem. > > loop: > > BTFSS S_PORT,S_PIN ;Check the start bit > goto receive > > NOP ;1'st instruction of code doing > ;something else > > BTFSS S_PORT,S_PIN ;Check the start bit > goto receive > > NOP ;2'nd instruction of code doing > ;something else > > ; repeat the above as often as needed to do the 'something else > routine' > > BTFSC S_PORT,S_PIN ;Last check of the start bit > goto loop > > receive > MOVF S_PORT,W > CLRF rx_data ;Assume all zeroes will be received > BTFSC S_PORT,S_PIN > BSF rx_data,7 ;got a 1, so set bit 6 (note rrf below) > > CLRF temp > BTFSC S_PORT,S_PIN > BSF rx_data,6 > > COMF temp,F ;temp = 0xff > BTFSC S_PORT,S_PIN > BSF rx_data,5 > > ANDLW 1< BTFSC S_PORT,S_PIN > BSF rx_data,4 > > CLRC > BTFSC S_PORT,S_PIN > BSF rx_data,3 > > ADDWF temp,W ;Put the first bit we received into C > BTFSC S_PORT,S_PIN > BSF rx_data,2 > > RRF rx_data,W ;Get the first received bit > BTFSC S_PORT,S_PIN > IORLW 1 > > MOVWF rx_data_stored ;3 cycles for stop bit (this could be > INDF, > ;but then we would need some clever -but > not > ;too hard - code.) > goto loop Very good, except that you read the MSB first. Let me rewrite the last part: receive MOVF S_PORT,W CLRF rx_data ;Assume all zeroes will be received BTFSC S_PORT,S_PIN BSF rx_data,0 CLRF temp BTFSC S_PORT,S_PIN BSF rx_data,1 COMF temp,F ;temp = 0xff BTFSC S_PORT,S_PIN BSF rx_data,2 ANDLW 1<