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

Why Serial Port not working with PIC16F887?

Go down  Message [Page 1 of 1]

jaltiti



I cannot get the serial Port to receive from PIC16F887. can you please show how to get it to work. Below is the code and attached is the simulation snap shot.

#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]);
}



Last edited by jaltiti on Mon Apr 17, 2023 9:40 am; edited 2 times in total (Reason for editing : Spelling and missing header file)

Back to top  Message [Page 1 of 1]

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