I agree, picuart.zip is definately a good read. I tied to follow it as a guide, but must have interpreted it incorrectly (I had problems getting it to work). Tony Nixon posted a sample for me last week or so that worked without issue. Check the archives. I changed his Receive routine to return instead of block if there is nothing to be read (I'm reading other inputs at the same time). I also changed it to clear/set the CREN bit in RCSTA, and read RCREG twice, if there is an overrun error (by checking the OERR bit of RCSTA). Kevin Here is the relevant part of Tony's post: ----------- From Tony Nixon ------------------------------- Here is a small program that should echo chars back to sender at 9600. I have used it successfully with the internal osc. Start movlw b'00000000' ; LVP lo, MCLR Lo movwf PORTA movlw b'00000100' ; RX Lo, TX Hi movwf PORTB bsf STATUS,RP0 movlw b'00000000' movwf TRISA movlw b'00000010' ; RX = input movwf TRISB bcf STATUS,RP0 ; ; ----------------------- ; DISABLE THE COMPARATORS ; ----------------------- ; movlw b'00000111' ; disable comparators movwf CMCON ; ; ------------------------------------ ; SET BAUD RATE TO COMMUNICATE WITH PC ; ------------------------------------ ; Boot Baud Rate = 9600, No Parity, 1 Stop Bit ; bsf STATUS,RP0 movlw d'25' ; 9600 baud movwf SPBRG movlw b'00100100' ; brgh = high (2) movwf TXSTA ; enable Async Transmission, set brgh movlw b'10010000' ; enable Async Reception clrf STATUS ; RAM Page 0 movwf RCSTA MnLoop call Receive movwf TXREG call TransWt goto MnLoop ; ; ------------------------------------ ; WAIT UNTIL RS232 IS FINISHED SENDING ; ------------------------------------ ; TransWt bsf STATUS,RP0 WtHere btfss TXSTA,TRMT ; transmission is complete if hi goto WtHere bcf STATUS,RP0 ; RAM Page 0 return ; ; ---------------------------------------- ; RECEIVE CHARACTER FROM RS232 OR INTERNAL ; ---------------------------------------- ; This routine does not return until a character is received. Receive nop btfss PIR1,RCIF ; check for received data goto Receive movf RCREG,W movwf RxHold ; tempstore data return -- Best regards Tony mICros http://www.bubblesoftonline.com mailto:sales@bubblesoftonline.com Byron A Jeff wrote: > > On Mon, Sep 24, 2001 at 06:30:31PM +0200, Joris van den Heuvel wrote: > > Hello everybody. > > > > I'm a first time poster, though I've been subscribed for some time now. I've been cut off from the US Internet area for days now, so I can't search the archives (blame my provider). Mail works fine. My question is this: > > > > I've recently migrated from the F84 to the F628. I used to do serial communication @1200 and 4800 baud using a software USART. All quite succesfully. But the USART in the F628 puzzles me a bit. Can someone provide me with the most basic sample routines on how to set up an 8 bits no parity 1 stop bit TX/RX comms line? Specific problems are: - how do I deal with error bits - and - which bits do I poll for (RCIF/TXIF?). I also have a signal coming in from a port pin that will have to immediately abort all communication. My current (professional) application doesn't use interrupts. I use assembly language. > > > > I appreciate any help you could give me. > > Here's the perfect document for you. It's Fr. Thomas McGahee's PICUART.zip. > It's an annotated program that describes almost every detail of the USART. > Find it here: > > http://redrival.com/mcgahee/picuart.zip > > Note that it's a ZIP file. > > The second resource that's always helpful is the Microchip Midrange Reference > manual. It contains detailed descriptions of every peripheral, including > the USART. Each with code examples. > > Hope this helps, > > BAJ > > -- > http://www.piclist.com hint: PICList Posts must start with ONE topic: > [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads