tejashs
Member level 1
hello,
i have recently started learning PIC microcontrollers. i have done a few programs on PIC 16F84 and 16F72 and that is all the experiance i got with PICs. now i was trying to use serial communication using PIC 16F873A. and having a lot of trouble with reiever part even for low baud rates. the trouble being reciever part dosent seem to be working properly.
here is my code
The output i expected is the it should display 'U' in terminal first then echo the character i type in the terminal but that is not happening.
I am getting a continuous stream of 'U's non stop. I am unable to figure out the problem... i think i did all the steps given in the datasheet can someone help me out in this.
i have recently started learning PIC microcontrollers. i have done a few programs on PIC 16F84 and 16F72 and that is all the experiance i got with PICs. now i was trying to use serial communication using PIC 16F873A. and having a lot of trouble with reiever part even for low baud rates. the trouble being reciever part dosent seem to be working properly.
here is my code
Code:
#include <htc.h>
__CONFIG(0x3ffa);
void init()
{
TRISC = 0xc0;
SPBRG = 12; // (4,000,000/4800baud/64)-1 for setting 4800baud
TXSTA = 0x20;
RCSTA = 0x90;
TXIE = 0; // disable TX interrupt
RCIE = 0; // disable RX interrupt
}
void main()
{
unsigned int i;
unsigned char temp = 0;
init();
while (1)
{
while(!TXIF);
TXREG = 'U';
while(!TRMT);
for (i = 0; i < 3000; i++);
while (!RCIF);
temp = RCREG;
for (i = 0; i < 3000; i++);
while (!TXIF);
TXREG = temp;
while (!TRMT);
//while(!TXIF);
for (i = 0; i < 6000; i++);
}
}
The output i expected is the it should display 'U' in terminal first then echo the character i type in the terminal but that is not happening.
I am getting a continuous stream of 'U's non stop. I am unable to figure out the problem... i think i did all the steps given in the datasheet can someone help me out in this.