RS232 Communication using PIC18F4520’s USART – PIC Microcontroller Tutorial

Summary of RS232 Communication using PIC18F4520’s USART – PIC Microcontroller Tutorial


This tutorial demonstrates RS232 communication between a PIC18F4520 microcontroller and a PC using a terminal program. It explains the necessity of a MAX232 level converter due to voltage differences between TTL and RS232 standards, providing a schematic for testing serial data transmission and reception.

Parts used in the PIC18F4520 RS232 Communication Project:

  • PIC18F4520 chip
  • PIC18F4550 chip (alternative)
  • MAX232 IC
  • ICSP connector
  • RESET switch
  • 20MHz crystal
  • C12 capacitor (0.1uF)
  • C6 capacitor (0.1uF)
  • PC with terminal software

RS232 can be used to communicate between a variety of devices. Like your MCU and a GSM module or a PC. In this tutorial we will demonstrate a link between a PIC18F4520 MCU and a standard PC. On PC we will run a terminal program like RealTerm or Hyperterminal.RS232 Communication using PIC18F4520’s USART PIC Microcontroller Tutorial A terminal program is used to send and receive text data. So any text send by the MCU will be visible on Terminal Screen and Any keypress you make on the PC keyboard will be send over RS232 to your MCU. This configuration is the simplest setup to test and understand RS232 communication. When you have enough knowledge you can replace the Terminal with your own PC end software for sending receiving data.

Connecting PIC18F4520 with a PC

In Serial Communication the line that is used to transmit data is called Tx and the line used to receive data is called Rx. The PIC MCU uses TTL level for logic that is a 1 is a 5v and 0 is 0v but RS232 standard uses different scheme for logic level, so we need a level converter in between.

Schematic for Testing Serial Communication with PIC18F4520

The above image show the schematic of circuit you will need to make. Most of the circuit is common for many other application too. The only specific part is the level converter which built around the MAX232 IC.RS232 Communication using PIC18F4520’s USART PIC Microcontroller Tutorial schematich

The heart of this unit is PIC18F4520 chip (you may also use PIC18F4550). The ICSP connector is used to download programs via a PIC programmer. RESET switch is used to reset the MCU so its start executing from the beginning of the program. A 20MHz crystal is the source of oscillation. C12 and C6 which are 0.1uF (Marking 104) should be placed as closed to the MCU as possible, they provide extra immunity to noise.

 

 

For more detail: RS232 Communication using PIC18F4520’s USART – PIC Microcontroller Tutorial

Quick Solutions to Questions related to PIC18F4520 RS232 Communication Project:

  • What is the simplest setup to test RS232 communication?
    A link between a PIC18F4520 MCU and a standard PC running a terminal program like RealTerm or Hyperterminal.
  • How do you send text from the MCU to the PC?
    The terminal program displays any text sent by the MCU on the Terminal Screen.
  • Can you send data from the PC keyboard to the MCU?
    Yes, any keypress made on the PC keyboard is sent over RS232 to your MCU.
  • Why is a level converter needed in this circuit?
    The PIC MCU uses TTL levels while RS232 uses a different logic scheme requiring conversion.
  • Which IC is used to build the level converter?
    The level converter is built around the MAX232 IC.
  • What is the function of the RESET switch?
    The RESET switch resets the MCU so it starts executing from the beginning of the program.
  • What provides the source of oscillation for the circuit?
    A 20MHz crystal serves as the source of oscillation.
  • Where should capacitors C12 and C6 be placed?
    They should be placed as close to the MCU as possible to provide extra immunity to noise.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter