On Wed, 24 Jun 1998 09:37:28 -0700 Scott Dattalo writes: >> > SEROUT: >> > RRF DATA,W ;reformat data to have: >> > XORWF DATA ; 1 = bit change >> > ; 0 = no bit change >> > ; >> > MOVLW (1<> > BCF S_PORT,S_PIN ;start bit >> > SKPNC ;bit 0 >> > XORWF S_PORT ; >> > BTFSC S_PORT,0 ;bit 1 >> > XORWF S_PORT ; >> > BTFSC S_PORT,1 ;bit 2 >> > XORWF S_PORT ; >> > BTFSC S_PORT,2 ;bit 3 >> > XORWF S_PORT ; >> > BTFSC S_PORT,3 ;bit 4 >> > XORWF S_PORT ; >> > BTFSC S_PORT,4 ;bit 5 >> > XORWF S_PORT ; >> > BTFSC S_PORT,5 ;bit 6 >> > XORWF S_PORT ; >> > BTFSC S_PORT,6 ;bit 7 >> > XORWF S_PORT ; >> > NOP ;delay >> > BSF S_PORT,S_PIN ;stop bit = 1 >> > RETURN >> > >> > This gives only 2 cycle per bit which is quite fast. >> > On a 4MHz pic, it can send max. 500KBps. > >Clever Reggie. I like it a lot. A method I had used for video was to rotate bits out of RAM then into a port: rrf data,f ;Get new bit from RAM rlf PORTB,f ;Rotate C into B.0 rrf data,f rlf PORTB,f etc. This is of course 2 instrs. per bit but it is possible to send a large number of bits contiguously (subject to how much RAM and program space you have). The output should be taken from bit 0 or 7 of the port. The other port bits can be used for inputs. Reggie's method avoids these limitations. It would be easy to convert several bytes of data to "differential" form before output, or just store it that way to begin with. If you're willing to sacrifice all of the I/O pins of >S_PORT then consider this single cycle resolution I posted a few >months >back: > >;PORT B, bit0 is the data output bit. All other port bits are >;configured as outputs, but are otherwise wasted > >; pre-calculate the parity. > > RRF parity,W ;Put Parity into Carry > MOVF data_byte,W > > CLRF PORTB ;start bit > > MOVWF PORTB ;d0 > RRF PORTB,F ;d1 and pick up the parity bit > RRF PORTB,F > RRF PORTB,F Obviously it's not going to get any faster than this. There needs to be a delay between bytes to load a new value for shifting. But for example outputting raster text to video, this isn't a problem because there needs to be a space between characters anyway. >And then Bill Cornutt wrote: > >> While the pic may be able to send at this speed, it >> would be hard for it to receive at the same speed. I wasn't worried about reception since it was just putting out video pixels. _____________________________________________________________________ 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]