It is available in microchip site itself.... once again read the datasheet of PIC16f877a
Code:
// U A S R T C O N F I G
TXSTA = 0b00100000;
SPBRG = 0x33; // Baud = 1200
RCSTA = 0x80; // Enable serial port and dis RX
void WriteUSART( unsigned char data )
{
while(!TXIF); // Wait till reg is empty
TXREG = data;
}
// For RX
// U A S R T C O N F I G
TXSTA = 0b00000000; // Tx Disables
SPBRG = 0x33; // Baud = 1200
RCSTA = 0x90; // Enable serial port and Rx
// Read RCREG if RXIF is set