Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Interfacing 89C51 Microcontroller with PC using UART

Status
Not open for further replies.

Sathiesh Kumar

New Member
I am interfacing 89c51 microcontroller with PC using UART... when i used the code below.. i can used to send and receive the messages in hyperterminal but its not the actual message.. for example if i send Z from PC, microcontroller returns it back by [ ... if i send w from PC , microcontroller returns back by sending u ... what might be the problem.. i also checked it for different baud rates.... i have used max232 ic in between microcontroller and rs232...
Compiler:MikroC for 8051
please check it...


Code:
char uart_rd;

void main() {
  
  UART1_Init(4800);               // Initialize UART module at 4800 bps
  Delay_ms(100);                  // Wait for UART module to stabilize
  
  UART1_Write_Text("Start");
  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
    }
  }
}
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top