EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Replies /  #include “reg51.h”  void

 #include “reg51.h”  void

|

Microcontroller › 8051 › 89c51 interfacing with rs232 as well as 16×2 LCD ›  #include “reg51.h”  void

March 10, 2013 at 4:10 am #9286
ronakpatel
Participant

 

#include “reg51.h”
 
 
void inici_serie (void)
{
 
 
 
PCON |= 0x80; // SMOD = 1; => transmition rate x2
 
SCON = 0x50; // Serial port in mode 1
 
 
TMOD |= 0x20; // Timer 1, in mode 2
// i. e., timer of 8 bits with autoreload
 
//TH1 = 256 – (((smod + 1) * f_xtal) / (384 * baud)); TH1 = 0xFA; // for baud = 9600
TL1 = TH0;
 
// Activa timer0
TR1 = 1;
}
 
char receive_char (void)
{
RI = 0;
 
return SBUF;
}
 
void send_char (char chr)
{
TI = 0; 
SBUF = chr 
while(!TI) 
TI = 0;
}
 
void send_msg (char *msg)
{
TI = 0;
 
while(*msg)
{
SBUF = *(msg++);
while (!TI); TI = 0;
}
}
 
 
void main (void)
{
char chr;
 
inici_serie();
 
send_msg (“Hello!n”);
 
while (1)
{
if (RI) // do echo of the character received
{
character = receive_char ();
send_char (chr);
}
}
}
 

RSS Recent Posts

  • Pnp transistor query March 5, 2026
  • H bridge current direction logic March 5, 2026
  • Sine wave oscillator schematic please? March 5, 2026
  • LM350K variable power supply March 5, 2026
  • Hello & a Request: Recommendations for obsolete Panasonic filter Capacitors. March 5, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise