Regulus Berdin wrote: > Sorry! I had made a big mistake. > > All BTFSC S_PORT, should have been BTFSC DATA, > I had pressed the send button w/o first checking :). > > Reggie > > ---------- > > From: Regulus Berdin > > To: PICLIST@MITVMA.MIT.EDU > > Subject: Fast serial out > > Date: Wednesday, June 24, 1998 2:36 PM > > > > Hi all, > > > > While reading the piclist on the topic about rs233, > > an idea came to me for sending fast asynchronous data. > > A similar routine may have been discovered and posted > > before. But just in case, I will share this to all. > > This routine is not yet tested and may contain bugs. > > > > 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. 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 RRF PORTB,F RRF PORTB,F RRF PORTB,F RRF PORTB,F RRF PORTB,F ;parity BSF PORTB,0 ;stop bit 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. 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<