Hi!
I«ve made this code to work with the pic16F877 and to activate the usart.
There is something wrong with it and I can«t figure out what.
If someone out there could help me out I would be very greatfull.
I already got some help, thanks for that.

my test code is suppose to work like this:
I am using a 20MHz kristall.
after setting up the baude rate and everything I whant to send a byte of
code to TX and then into RX. when RX gets the code it should be shown at
PORTB.

This is just a test to get the darn thing to work. after that I will connect
this to a pc.

here is the code, a little messy:
thanks
//nabil

;**********************************************************************

org  0x000
nop
clrf PCLATH

Start

;*** Port setup ***


     bcf       STATUS,5
     clrf      PORTC          ;Clear PORTC
     clrf      PORTB
     bsf       STATUS,5       ;Bank 1
     movlw     0x80      ;Clock input port !!! change to 0x3F
     movwf     TRISC          ;
     movlw     0x00      ;Data input port  !!! change to 0x3F
     movwf     TRISD          ;

;--- Port setup ---

;*** Serial port init ***

     bsf   STATUS,5  ;Bank 1

movlw     0x81      ;20M/9600
;    movlw     .51       ;16M/19200
;    movlw     .64       ;20M/19200
     movwf     SPBRG
     bsf  TXSTA, BRGH
     bcf  TXSTA, SYNC
     bcf  STATUS,5
     bsf  RCSTA, SPEN
     bsf  RCSTA, CREN
     bsf  STATUS,5
     bsf  TXSTA, TXEN     ;gvr porten klar att skicka information
     bsf  STATUS,5

     ;clrf      TXREG

send_data

poll_1
     ;btfss     PIR1, TXIF     ;TX empty?
     ;goto poll_1              ;if no

     movlw     0x91
     bcf       STATUS,5
     movwf     0x19           ;b'10010001'


get_data
     bcf      STATUS,5
poll_2
      btfss    PIR1,RCIF
      goto     poll_2

      bcf      STATUS,5
      movf     RCREG,0
      movwf    PORTB

end