Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

PIC16F887 and Serial Port Issue

2 posters

Go down  Message [Page 1 of 1]

1PIC16F887 and Serial Port Issue Empty PIC16F887 and Serial Port Issue Mon Apr 17, 2023 9:48 am


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.

#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");
  Send_String("UAE - DUBAI \n\r");

void SerTx(unsigned char x)
  TXREG = x;

void Send_String(unsigned char *text)
  unsigned char i;
  for (i=0; text[i]!='\0'; i++)

2PIC16F887 and Serial Port Issue Empty Re: PIC16F887 and Serial Port Issue Thu Apr 20, 2023 9:41 pm



That is probably an error in baudrate.
Is the MCU frequency set to 4 MHz?

Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum