1. I assume that because you are using 129 for SPRG & 9600 baud, that your clock speed is 20 MHz, right ? 2. The code should run as is, starting outputting a null (0) follwed by the control codes, and other printables. Perhaps you wanted to pre-load the counter with the 0x20 (ASCII space) so you can see printables appear in your terminal at the other end ? 3. you didn't really say what wasn't working - if it couldn't compile (with MPASM) then add list p=16C876 #include p16C876.inc at the top. HTH ---------------------------------------------- Kenneth C. Finney ============================================== Wilkes Associates, Inc. Software Engineering - Embedded Systems Design & Development - Project Management ============================================== 170 The Donway West Ste. 405, Toronto, Ontario Office: (416) 445-9224 Mobile: (416) 453-6400 ---------------------------------------------- > -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Paul A Brown > Sent: Wednesday, August 04, 1999 11:38 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: Hardware Serial Ports > > > I have some questions regarding the use of the hardware > serial port on a > PIC16F876. All I want to do is initialize tbe serial port > to 9600 baud, > asynchronous and spew out some data. I have looked at this > code until my > eyes hurt, but to no avail. Could somebody point out where > I am going > wrong? Does anyone have any sample transmit or receive code for the > hardware serial ports that they would like to share? > > Thanks, > > Paul Brown > > > ; Registers > Cntr equ 0x20 > > > ;Initialize variables > clrf Cntr > > > ;Initialize serial port > SerInit > bsf RCSTA, SPEN > bsf STATUS, RP0 > bcf TXSTA, SYNC ;Asynchronous transmission > bsf TXSTA, BRGH ;Baud rate generator to high speed > movlw 129 > movwf SPBRG ;Set BRG for 9600 buad. > bsf TXSTA, TXEN ;Enable transmit > bcf STATUS, RP0 > > ;Main Program Loop > MainLoop > bsf STATUS, RP0 > btfsc TXSTA, TRMT ;Check for data sent > goto TxData > goto MainLoop > > > ;Increment Counter and Transmit > TxData > bcf STATUS, RP0 > incf Cntr, 1 > movf Cntr, 0 > movwf TXREG > goto MainLoop > > end > > ___________________________________________________________________ > Get the Internet just the way you want it. > Free software, free e-mail, and free Internet access for a month! > Try Juno Web: http://dl.www.juno.com/dynoget/tagj. >