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.
 
I would imagine you've written your PIC program to do exactly that?, and that the small fragment you've posted is inside a loop.
 
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);
}
}
}
 
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.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…