I cannot get the serial Port to receive from PIC16F887. can you please show how to get it to work. Below is the code. I can see through the PIC serial monitor the message "PCT DBM" and "UAE - DUBAI" are sent sent but the serial port serial monitor receive weired characters. The config for the serial port (9600, 8 bits, 1 stop bit) matches the PIC settings.
#include
#define _XTAL_FREQ 4000000
void Send_String(unsigned char *Str);
void SerTx(unsigned char);
void main(void)
{
TXSTA = 0x20;
SPBRG = 25;
SPBRGH = 0;
RCSTA = 0x80;
Send_String("PCT DBM \n\r");
__delay_ms(30);
Send_String("UAE - DUBAI \n\r");
while(1);
}
void SerTx(unsigned char x)
{
TXREG = x;
while(PIR1bits.TXIF==0);
}
void Send_String(unsigned char *text)
{
unsigned char i;
for (i=0; text[i]!='\0'; i++)
SerTx(text[i]);
}
#include
#define _XTAL_FREQ 4000000
void Send_String(unsigned char *Str);
void SerTx(unsigned char);
void main(void)
{
TXSTA = 0x20;
SPBRG = 25;
SPBRGH = 0;
RCSTA = 0x80;
Send_String("PCT DBM \n\r");
__delay_ms(30);
Send_String("UAE - DUBAI \n\r");
while(1);
}
void SerTx(unsigned char x)
{
TXREG = x;
while(PIR1bits.TXIF==0);
}
void Send_String(unsigned char *text)
{
unsigned char i;
for (i=0; text[i]!='\0'; i++)
SerTx(text[i]);
}