svinoth86
Newbie level 6
how to interface serial communicationn with pic16f877a?
---------- Post added at 13:51 ---------- Previous post was at 13:51 ----------
#include<htc.h>
unsigned char sr_rx()
{
unsigned char r;
while(!RCIF);
r=RCREG;
RCIF=0;
return r;
}
sr_tx(unsigned char t)
{
TXREG=t;
while(!TXIF);
TXIF=0;
}
void main()
{
unsigned char a;
//TRISC=0xff;
//PORTC=0xff;
TXSTA=0x24;
RCSTA=0x90;
SPBRG=0x19;
while(1)
{
// sr_tx('b');
a=sr_rx();
sr_tx(a);
}
}
---------- Post added at 13:51 ---------- Previous post was at 13:51 ----------
#include<htc.h>
unsigned char sr_rx()
{
unsigned char r;
while(!RCIF);
r=RCREG;
RCIF=0;
return r;
}
sr_tx(unsigned char t)
{
TXREG=t;
while(!TXIF);
TXIF=0;
}
void main()
{
unsigned char a;
//TRISC=0xff;
//PORTC=0xff;
TXSTA=0x24;
RCSTA=0x90;
SPBRG=0x19;
while(1)
{
// sr_tx('b');
a=sr_rx();
sr_tx(a);
}
}