In the last two tutorial we discussed how to make the hardware for serial communication and how to setup a MPLABX Project with support for serial communication functions. Then we complied a demo program to use those serial communication functions and burnt the final hex file to our PIC16F877A development board. Now its time for us to run this demo.
To interact with this demo running on your PIC development board. You need a terminal program. A terminal program is a utility tool running on PC that helps you view text data coming from the serial port and also send data to the port. This is handy for initial development of connected hardwares.
We use Real Term for this purpose.
You can download it from here.
The top black area show the character data as they are received by the serial port. The received characters are shown in YELLOW coloured text.
The bottom area has lots of tab on it.
The Port tab (shown above) is used to configure the serial port. Configure the port exactly as show in the image above.
- Baud = 9600
- Port = <the serial port number where you have connect the PIC development board>
- Parity = None
- Data Bits = 8 bits
- Stop Bits = 1 bit
- Hardware Flow Control = None
- Make sure "Open" button is NOT pressed !
After RealTerm has been started and configured correctly connect the USB to RS232 Converter on your PC’s USB Port
Fig. USB to Serial Converter
Then connect the DB9 Male Part of it (the other end) to your PIC Development Board and Click the Open button on RealTerm.
Fig. Serial Port Connected
Power up the development board using a 12V 1A Adapter.
You will received a message on RealTerm as shown in the image below. This message is sent by the PIC over the serial port.
Data shown on Terminal Window
Once you receive this message, you can be sure that data is easily flowing from the PIC microcontroller to the PC. But now we also need to check if the data is able to reach the MCU from the PC or not.
For this, click on the top large black area of RealTerm and then press any key on the keyboard of your PC. RealTerm will send those data to MCU and if MCU is able to read those data, it will reply back with the same character but enclosed in a <>. That means if you press ‘a‘ on keyboard you will see <a> on the terminal window.
This confirms that MCU is also able to read data from the serial port.
Finding the COM Port Number
On windows desktop right click on Computer Icon
Select Properties from the context menu.
This will open up system properties.
From the left hand side, select Device Manager as shown in the image above. It will open up the Device Manager
Expand the Ports (COM & LPT) node as shown in the image above. Find the Port Named Prolific USB-to-Serial Comm Port and note the number shown next to it in brackets.
In our case it is COM2 that’s why we have opened Port 2 in RealTerm
Open Port 2 in Real Term
Important Note !
In order to use the USB to Serial Adapter, it’s driver must be installed correctly ! You can download the drivers from here.
By Avinash Gupta
Just try EasyEDA editor, Start to design your own circuit and PCB easily
JLCPCB Prototype: Only $2 for 10pcs 10×10cm PCBs, 2-3 days delivery
Electronic Parts Online Store LCSC: Save 50% on cost, Wide selection in-stock
Facing problem with your embedded, electronics or robotics project? We are here to help!
Post a help request.