UART - 8051

  • MICROCONTROLLER - AT89S51 
  • COMPILER - MIKROC
  • SIMULATION - PROTEUS 8.1
  • CRYSTAL - 11.0592MHz(use this crystal to get baud rate of 9600)


CIRCUIT

x-ctu screen shot

PROGRAM
//RX PIN 10  (P3_0)
//TX PIN 11 (P3_1)


char uart_rd;

void main() {

  UART1_Init(9600);               // Initialize UART module at 4800 bps

  Delay_ms(1000);                  // Wait for UART module to stabilize

  UART1_Write_Text("haiii");

  while (1) {                     // Endless loop
    if (UART1_Data_Ready()) {     // If data is received,
      uart_rd = UART1_Read();     //   read the received data,
      UART1_Write(uart_rd);       //   and send data via UART
    }
  }

}