I am working on UART configuration for pic16f877a and want to configure registers for UART ...
I have looked datasheet of pic16f877a I don't understand the correct way for the UART configuration so could anyone help to configure register.
I have attached pic16f877a datasheet. page 112, 113 uart
TXSTA :Transmit Status And Control Register
RCSTA : Receive Status And Control Register
SPBRG : USART Baud Rate Generator
TXREG : USART Transmit Register. Holds the data to be transmitted on UART
RCREG ; USART Transmit Register. Holds the data received from UART
This is my configuration
I have looked datasheet of pic16f877a I don't understand the correct way for the UART configuration so could anyone help to configure register.
I have attached pic16f877a datasheet. page 112, 113 uart
TXSTA :Transmit Status And Control Register
RCSTA : Receive Status And Control Register
SPBRG : USART Baud Rate Generator
TXREG : USART Transmit Register. Holds the data to be transmitted on UART
RCREG ; USART Transmit Register. Holds the data received from UART
This is my configuration
Code:
void main (void)
{
TX9D = 0
TSR = 1; // TSR empty
SYNC = 1; // Synchronous mode
TXEN = 1; // Enables Transmission
TX9 = 0 ; // Transmission as 8bit transmission
CSRC = 1;
RX9D = 0 ;
OERR = 1 ; // Overrun error
FERR = 0 ; // No framing error
ADDEN = 0 ; // Disables address detection
CREN = 1 ; // Enables continuous receive
SREN = 1 ;
RX9 = 0 ; //Selects 8-bit reception
SPEN = 1 ; //Serial port enabled
BRGH = 0 // Low speed mode
SPBRG = 0;
}
Attachments
-
82.2 KB Views: 6
-
60 KB Views: 5
-
4 MB Views: 2
