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.

Redarding serial receiver and transmitter

Status
Not open for further replies.
I'm suggest you to use the serial interrupt and buffer to receive the serial data. It is better.
 

Code:
#include<reg51.h>
#include<stdio.h>

Rx();
Tx();

void main (void)
{
SCON = 0x42;
TMOD |= 0x20;
TH1 = 0xfa;
TR1 = 1;
TI = 1;
Rx();
}

Rx(){
while (1)
{ (RI=1);
ACC = 0000;
ACC = SBUF;
P1 = ACC;
Tx();
RI = 0;
Rx();
}
}

Tx()
{
ACC = (ACC + 4Cool;
SBUF = ACC;
while(TI){}
TI = 0;
your code is completely wrong and it should not work. first of all you have misused while loop, Second Rx function calls itself-an infinite loop within an infinite loop. First learn about Interrupt Service Routine(ISR), then handle transmission interrupts(Rx, Tx) in their corresponding ISR. As Others suggested it will be better to implement a buffered scheme for your ISRs.
 

you should ,first return from isr otherwise how you can re-enter in it on event ?

Rx(){
while (1)
{ (RI=1);
ACC = 0000;
ACC = SBUF;
P1 = ACC;
Tx();---------------------------------error remove it
RI = 0;
Rx();---------------------------------error remove it
}
}
 

manish12 said:
you should ,first return from isr otherwise how you can re-enter in it on event ?

Rx(){
while (1)
{ (RI=1);
ACC = 0000;
ACC = SBUF;
P1 = ACC;
Tx();---------------------------------error remove it
RI = 0;
Rx();---------------------------------error remove it
}
}

After removing the two (tx(), rx()) warning shows as uncalled segment, ignored for overlay process
Segment: ?pr?tx?rxtx?
 

Hi,

Exclude the function definitions of Tx & Rx . I hope you are done with ISR code.



With Regards
S.Rajesh Kumar
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top