- PIC16f877 Microcontroller
- 16×2 lcd
- PC with DB-9 or DB-25 Port
- Potentiometer (For Setting LCD Contrast)
- Crystal 20MHz
- Connecting Wires & Power Supply
Microcontrollers works on TTL(Transistor Transistor Logic) wave form & standard PC(Personal Computers) works on RS-232 level wave form. Serial Data Transmitted by PC is in RS-232c level wave form. We have to convert this RS-232c wave form data in TTL form, to pass it to PIC16f877. The best way is to use MAX-232 ic. MAX-232 converts RS-232c level wave form data in TTL & TTL data in RS-232c level. Below is a simple Diagram of both the wave forms.
Serial communication using Pic microcontroller – Circuit diagram
USART of PIC 16f877 is present at Pin 25 & 26 of PIC 16f877 Microcontroller. USART Include Port-C Pin#6 & 7. RC6 can be used as TX(Transmission) and RC7 can be used as RX(Reception). Since we are receiving data from PC and then displaying it on 16×2 lcd so we are only concerned with RX(Reception) pin of USART. This RX pin is connected to Pin#12(R1OUT) of MAX-232. Pin#13(R1IN) of MAX-232 is connected to PIN#3 of DB-9 Port.
Both the tutorials above are very important for you, if you are new and didn’t use the stuff before in any project. I recommend you to go through them it will help you a lot in understanding the circuit diagram and working of both the things. Circuit diagram of the project is given below.
Pic microcontroller serial communication – Project code
In the main function first TRISC7=1 is initializing RX pin as input. TXSTA(Transmit Status and Control Register) is initializing USART in Asyncronous Mode with High Speed Baud Rate. 0x04 is loaded in TXSTA.
The data received at RX pin is placed in RCREG register. When any byte is received, RCREG register becomes full and it raises RCIF(Receive interrupt flag) flag of PIR1 register. When RCIF flag becomes high i pick data from RCREG register. This logic is implemented in while(1) loop. While one continuously receive data from PC.
See The Project Video Here…
Filed Under: Microcontroller Projects, PIC Microcontroller