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.

serial communication 8051

Status
Not open for further replies.

Jogisant

Newbie level 3
Joined
Jul 21, 2012
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,313
HI

MCU 89c51, baud rate same 19200
I am facing a problem while serial interfacing of two MCU or one MCU with virtual terminal .
Actually whenever one bit gets transmitted, the receive ISR of MCU gets triggered automatically, but there is no request from other mcu.
Then it never come out also, I am unable to understand why the ISR gets triggered, when RI is also not getting 1.
Now when I write an if command to check If(RI==1), then answer is false and program does not enter inside .
Please help me with detailed steps in serial communication.

AS I was assuming that whenever a data(bit) gets transmitted , the MCU checks if there is any bit on reception or not.
or otherwise if this not true then when is the protocol being followed by MCU for serial communication.

PLease find enclosed the code as well.


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
void transmit_data(unsigned char *tx)                       // Function to transmit data through serial port
{
    int i =0;   
    lcd_cmd(0x01);lcd_cmd(0x80);
    lcd_string("txn begins");
    while(tx[i]!='\0')
    {
        SBUF=tx[i];                                         // Store data in SBUF
        lcd_char(tx[i]);
        txn_arr[i]=tx[i];
        while(TI==0);                                       // Wait till data transmits
        delay(10);
        TI=0;
        i++;
    }
    //SCON=0x50;
}
 
void receive_data() interrupt 4                             // Function to transmit data through serial port
{
    //char arr[10];
    int i =0;   
 
    if (RI==1)
    {
        lcd_cmd(0x80);
        lcd_string("recv");
        RI=0;
        rx[i]=SBUF;                                         // Store data in SBUF
        lcd_char(rx[i]);
        delay(10);
    }
}




Plz also tell me what is the function of REN in SCON.

Thanks in anticipation.
Rahul Mittal.
(rahul.kcsl@gmail.com)
 
Last edited by a moderator:

REN bit in scon register enables the reception of data serially. if u make REN=0 and force mc to receive data, it cannot receive so to receive data REN=1.
 

REN bit in scon register enables the reception of data serially. if u make REN=0 and force mc to receive data, it cannot receive so to receive data REN=1.


You are right sir, but the point is if make SCON as 0x40 (in order to not activate REN) , then also the isr of receive gets activated.

- - - Updated - - -

You are right sir, but the point is if make SCON as 0x40 (in order to not activate REN) , then also the isr of receive gets activated.

Now I could figure out that, it was my mistake assuming serial int isr as receive isr , Now that is cleared but please clear me one more thing when TI gets high, does that mean that sbuf got last bit and is ready for transmission or it means transmission has already happened and stop bit is getting transmitted.

Please help me more on serial communication protocol at MCU side.
 

yes you are right, when last bit(stop bit) is getting transmitted then TI becomes high to indicate that data transmission is been done, and mc is ready to transmit next byte of data.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top