Share on facebook
Share on twitter
Share on linkedin
Share on whatsapp

Serial communication with PIC 16f877 using UART

Here you will find the very important topic discussion on serial communication with PIC 16f877 using UART.  For make you understand better way i discuss one project regarding serial communication with PIC 16f877 using UART. I know if you learn UART interfacing with PIC microcontroller then lots of projects window open infront of you. So carefully go through the abstract of project.

Abstract of that project:

Using UART port we can establish serial communication between any devices. Here in my project Serial communication with PIC 16f877 using UART, I will show you how easily we establish communication between two devices. lets start discussion i think we should know that the pin no 25 and 26 in PIC16F877 microcontrller are used as UART. The pin number 25 is use for receiving and 26 is used for transmitting purpose.

Hardware needed:

In early discussion abstract of that project we learn about responsible pins of PIC16f877 for UART. Now we see the circuit diagram bellow we use MAX232,UART port, PIC16f877 and LCd (Lm106L) to make our project.

Serial communication with Pic 16f877 using UART

For Simulation:

we know Simulation software is a main weapon of a design engineer. For that we use Mikcro C pro to write the embedded C program for PIC16F877. We used Proteus 7 Professional for simulation. And for simulation of our project serial communication with PIC 16f877 using UART, we replace COMPIM and MAX232 with Virtual UART Terminal.

So see our replace circuit for simulation in Proteus in bellow of project serial communication with PIC 16f877 using UART.

Serial communication with Pic 16f877 using UART

Mikcro C Pro Code:

To interfacing UART with Pic we have to use some new command those are

UART1_Init(Baudrate):is Initialize UART module at specified baudrate.

 UART1_Data_Ready() : use to check data is receive or not.

 UART1_Write_Text(“Start”): use to write declared text on uart

 UART1_Write(): use for transmit uart data.

 UART1_Read(): use for read the uart data.

 Now see at below the programing code to understand use of above mention command.

See embedded Code

 
Embedded C Code
// Name : Serial Communication
// Purpose : To establish serial communication.
// Author : Subham Dutta
// Date : 25-09-13
// Website : www.nbcafe.in
unsigned int uart_rd;
sbit LCD_RS at RD2_bit;
sbit LCD_EN at RD3_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_RS_Direction at TRISD2_bit;
sbit LCD_EN_Direction at TRISD3_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
void main()
{
int i;
lcd_init();
ANSEL = 0;                        // Configure AN pins as digital
ANSELH = 0;UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100);           // Wait for UART module to stabilizewhile (1)
{                                          // Endless loop
if (UART1_Data_Ready())
{                                          // If data is received,
uart_rd = UART1_Read();
UART1_Write(uart_rd);      // read the received data,
if (uart_rd == 8)
{
lcd_cmd(_LCD_MOVE_CURSOR_LEFT);
lcd_cmd(_LCD_MOVE_CURSOR_LEFT);}
lcd_chr_cp(uart_rd);}
}
}

See the video that how it simulate in Proteus

Not Enough, Need More

E-Mail Subscription





9 thoughts on “Serial communication with PIC 16f877 using UART”

  1. hi .. amazing can you send me some codes of receiving sms?? thanks a lot…. here is my email :kenstengerez@ymail.com

  2. i am interested of this project , but i have error with
    ANSEL = 0; // Configure AN pins as digital
    ANSELH = 0

    >> Undeclared identifier ‘ANSEL’ in expression
    >> Undeclared identifier ‘ANSELH’ in expression

    thank you for your help .

  3. Hi,
    i am interested of this project , but i have error with
    ANSEL = 0; // Configure AN pins as digital
    ANSELH = 0

    >> Undeclared identifier ‘ANSEL’ in expression
    >> Undeclared identifier ‘ANSELH’ in expression

    thank you for your help .

  4. Hey nice project, can you send me the circuit diagram, the image has a low resolution and i dont see the terminal names

Comments are closed.

E-Mail Subscription





Table of Contents
Subham Dutta

Subham Dutta

Hi myself Subham Dutta, having 15+ years experience in filed of Engineering. I love to teach and try to build foundation of students. Try to make them imagine what they learn.

Need more this type of content in your E-Mail?



NBCAFE