navintiwari08
Newbie level 2
- Joined
- Jul 27, 2013
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 20
hello there!
I'm trying to communicate with PC using pic16f877a's uart.. I've written a code in HITECH C.. but it doesn't seem to work.. pls help.. I'm using 20 MHz crystal and 9600 bauds..
the code is given below..
I'm trying to communicate with PC using pic16f877a's uart.. I've written a code in HITECH C.. but it doesn't seem to work.. pls help.. I'm using 20 MHz crystal and 9600 bauds..
the code is given below..
Code:
#include <htc.h>
#define _XTAL_FREQ 20000000
__CONFIG(FOSC_HS&LVP_OFF&CP_OFF&BOREN_OFF&PWRTE_OFF&WRT_OFF&WDTE_OFF);
unsigned char x;
void main()
{
TRISC6 = 1;
TRISC7 = 1;
BRGH = 1;
SYNC = 0;
SPEN = 1;
SPBRG = 129; //9600 baud with 20MHz
TXIE = 1;
RCIE = 1;
GIE = 1;
PEIE = 1;
CREN = 1;
TXEN = 1;
while(1);
}
void interrupt ISR(void)
{
if(RCIE && RCIF)
{
x = RCREG;
if(TXIF)
TXREG = x;
__delay_ms(100);
}
}