Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

8051 C Code for Serial Communication problem ?

Status
Not open for further replies.

Qasim Khokhar

Member level 1
Member level 1
Joined
Aug 15, 2013
Messages
35
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Lahore
Visit site
Activity points
1,514

if i never set TI=1 then this code not work in proteus. and if i set TI=1 than 8051 transmit parallel to receiving


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <reg51.h>
#include <stdio.h>
#include <lcd.h>
 
 
sbit RS = P2^1;
sbit EN = P2^0;
sbit WR1 = P2^2;
sbit D0 = P1^0;
sbit D1 = P1^1;
sbit D2 = P1^2;
sbit D3 = P1^3;
sbit D4 = P1^4;
sbit D5 = P1^5;
sbit D6 = P1^6;
sbit D7 = P1^7;
 
void Delay(int a)
{
  int j;
  int i;
  for(i=0;i<a;i++)
  {
    for(j=0;j<100;j++)
    {
    }
  }
}
void main()
{
 int i;
        char buf='\0';
        SCON  = 0x50;               /* SCON: mode 1, 8-bit UART, enable rcvr      */
    TMOD |= 0x20;               /* TMOD: timer 1, mode 2, 8-bit reload        */
    TH1   = 0x0E8;                /* TH1:  reload value for 1200 baud @ 16MHz   */
    TR1   = 1;                  /* TR1:  timer 1 run                          */
        IE=0x90;
[B]     RI=0;
    TI=1;
[/B]  WR1=0;
    Lcd8_Init();
    Lcd8_Set_Cursor(1,1);
    while(1){
        while((buf=getchar())==NULL);
    Lcd8_Write_Char(buf);
}
    while(1);   
}

 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top