On Tue, 2 Jun 1998 19:55:43 -0700 WF AUTOMACAO writes: >Nichole, Petty@ambiente.com.br wrote: >> >> Hello >> >> Does anyone have a working serial routine for a 16F84. I can't get >mine to >> work. I'd like to compare mine with a working routine. I want to run >9600 or >> 19200, inverted. Here's one I know works from a recent project of mine. With a 3.6864 MHz crystal, it sends at 9600 baud. You can change the timing constant to get other rates. It sends what I would call "non-inverted"; the levels at the PIC pin are high for start bits and zeros, and low for stop bits and ones. This signal can be connected directly to most PC's which happen to accept TTL levels on the RS-232 port. If you want the other polarity of data to use with a line driver, just reverse the bsf and bcf on _rsout. It needs two RAM locations and a #define for _rsout such as this one: #define _rsout PORTB,0 ;---------------- serout ; Outputs a byte in RS-232 (8N1) to the '_rsout' pin. ; With 3.6864 MHz PIC xtal, baud rate will be 9600. ; Polarity is correct to connect the pin directly to the RS-232 line. ; If inverting line transmitter is used, need to modify for opposite ; polarity. ; Input with byte to send in W. Uses bitct, sreg. movwf sreg ;Save W to shift later. movlw .10 movwf bitct clrc ;Start bit is a 0. serout_l skpc ;Sending 1? bsf _rsout ;No, send 0. skpnc ;Sending 0? bcf _rsout ;No, send 1. movlw .255 - .21 ;Setup for delay. serout_d addlw 1 ;Keep increasing W skpc ;until it overflows. goto serout_d ;(C must be 1 here, so proper stop bits are placed in sreg.) rrf sreg,f ;Get another bit out. decfsz bitct,f ;Send another bit? goto serout_l ;Yes. return ;Done. _____________________________________________________________________ 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]