• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Serial Communication Error(Data Keeps Looping)

Status
Not open for further replies.

vandalist

New Member
Hello.Basically i have my 16f877a connected to the pc using a max232 and db9 interface.i can send data from the hyper terminal to the pic fine.but when i try 2 send data from the pic to the pc it keeps looping ex:

if(PORTB.F1==1)
{
Usart_Write(0x61);
}
the hyper terminal keeps receiving 0x61 a lot.i want it to recieve it once then stop it keeps looping like this
Received 0x61
Received 0x61
Received 0x61
Received 0x61
Received 0x61
Received 0x61
Received 0x61

i need it to receive once and stop untill further action.Thanks in advance.
 

vandalist

New Member
here is my code

void main ()
{
TRISB.F0=1;//set pin 0 in port b as input
Usart_Init(9600);
while(1)

{
if(PORTB.F0==1)
}
Usart_Write(0x61);
}
}
}
 

smanches

New Member
Code:
while(1)
{
   if(PORTB.F0==1)
   {
      Usart_Write(0x61);
   }
}
There's your loop.
 

Diver300

Well-Known Member
Most Helpful Member
I won't make an idiot of myself by trying to write code in C, as I use assembly, but what you need to do is:-

When PortB, 0 is off, clear a flag

When PortB, 0 is on and the flag is clear, set the flag and transmit 0x61

That will transmit 0x61 once each time PortB, 0 turns on.
 
Status
Not open for further replies.

EE World Online Articles

Loading
Top