Livingston
Full Member level 2
- Joined
- Nov 26, 2007
- Messages
- 129
- Helped
- 3
- Reputation
- 6
- Reaction score
- 1
- Trophy points
- 1,298
- Location
- Chennai-India
- Activity points
- 2,104
yyy y
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
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.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;
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
}
}