pic16f877a uart io conflict

Thread Starter

nagesh.bsnl

Joined Jul 1, 2012
2
Hello guys!
I am having a problem with pic16f77a uc. i make pin B4 as i/p and pin B5 as o/p.i give +5V(same source as given to pic and MAX232) to pin B4 so that B5 goes high and UART sends a charecter to hypertreminal. the code is :
#if defined(__PCB__)
#elif defined(__PCM__)
#include <16F877A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
void main()
{
set_tris_b(0x1f);
while(true)
{
if(input(PIN_B4)==1)
{
output_high(PIN_B5);
putc(0x42);
delay_ms(200);
}
if(input(PIN_B4)==0)
{
output_low(PIN_B5);
putc(0x44);
delay_ms(200);
}
}
}
but whenever i connect RS232 cable, all PORTB pins goes to high and low alternatively for some period irrespective of its configuration.wat might be the problem? also is it correct way to apply +5V to input pin?i ve tried this in MICROC, Hitech C v.9.83 and facing the same problem. plz help me out, i am new to programming...
 
Top