Study and Development of PIC Microcontroller-to-PC Communication Via USB
Study and Development of PIC Microcontroller-to-PC Communication Via USB
Key words: PIC microcontroller, FSUSB framework, Abstract: In this study, researchers attempt to describe a
MPLAB IDE, MPLAB C18 compiler, USB study and development of PIC microcontroller-to-PC
communication, bootloader communication via USB. The microchip FSUSB
framework utilized the PIC18F4553 with 20 MHz crystal.
Corresponding Author: Port B pin RB4 has been used as bootloader and RD0 and
M.N. Islam RD1 as the status indicator. Moreover, RC5 and RC4 of
Electronics Division, Atomic Energy Centre, Bangladesh PortC have been used as USB D+ and D-. Firmware tools
Atomic Energy Commission, P.O. Box No. 164 Dhaka, consist of MPLAB IDE, MPLAB C18 compiler, driver,
Bangladesh FSUSB framework V2.6 and Microsoft Visual Stadio
(Visual C/C Sharp). Demonstration and Development of
Page No.: 75-78 a complete USB2.0 communication solution has been
Volume: 13, Issue 3, 2020 verified by using USB Device-CDC-BASICDEMO
ISSN: 1997-5422 Software on Proteus 7.7 Simulation platform.
International Journal of Systems Signal Control and
Engineering Application
Copy Right: Medwell Publications
USB as its name would suggest is a Universal Serial A study and development of PIC microcontroller-to-
Bus (USB). It uses 4 shielded wires of which two are PC communication via USB has been presented in this
power (+5 V and GND). The remaining 2 are twisted pair research. The system consists of microchip FSUSB
differential data signals USB D+ and D-. It uses a Non framework utilized the PIC18F4553 with 20 MHz crystal.
Return to Zero Invert (NRZI) encoding scheme to send Block diagram, microchip FSUSB framework, circuit
data with a sync field to synchronise the host and receiver description and demonstration for the system have been
presented accordingly (Fig. 1).
clocks.
Therefore, serial communication between
Block diagram
microcomputer and microcontroller has been presented
Schematic diagram: Complete simulation model of the
that describes a data transmission system where the data primitive hardware used in the microchip FSUSB
can be transmitted from a personal computer to a framework on Proteus 7.7 Simulation platform has been
microcontroller chip and vice-versa[1-3]. In the present shown in Fig. 2. The description of schematic diagram has
research, a study and development of Universal Serial Bus been presented as:
(USB) communication between a PIC microcontroller and
the Personal Computer (PC) has been presented. A Input power filter circuit: A power supply must provide
complete USB2.0 communication solution has been stable and ripple-free DC output voltage independent of
verified by using USB device-CDC-BASICDEMO line and load variations[4, 5]. Therefore, the input power
Software on Proteus 7.7 Simulation platform. filter circuit consists of capacitors C1 and C2.
75
Int. J. Syst. Signal Control Eng. Appl., 13 (3): 75-78, 2020
Device PC side
Fig. 2: The primitive hardware used in the microchip FSUSB framework on Proteus 7.7 Simulation platform
76
Int. J. Syst. Signal Control Eng. Appl., 13 (3): 75-78, 2020
clock input. CPU, 4-ports, reset, memory for data and one of the USB ports. Run the bootloader application
program, interrupts and free-run timer TMR0[6]. A high “PDFUSB.exe” located on “C:\Microchip Solutions\USB
level language program developed using C controls the Tools\Pdfsusb”.
function of the processor.
Driver: The current research is a simulation in the
Status indicator and USB: The status indicator circuit microchip FSUSB framework on Proteus 7.7 Simulation
constructs with resistors R1, R2 and LEDs D1, D2 (RED). platform. Otherwise, its need driver file installation for
And RC5 and RC4 of PortC have been used as USB D+ introducing the device to PC. The same thing goes for the
and D-. user interface and FSUSB framework with suitable
version[7].
RESULTS AND DISCUSSION
Demonstration and analysis: The demonstration and
Software arrangement development of the PIC microcontroller-to-PC USB
MPLAB IDE: The MPLAB IDE Software brings an ease communication has been presented in this research. One
of software development previously unseen in the 8/16 bit can easily understand the operation of the code by looking
microcontroller market. The MPLAB IDE is a Windows at the events and function declarations. It is a well
based application in which main.c program has been commented code allowing the programmer to understand
developed to control the operation of the PIC the basic operations used to send and receive functions
microcontroller-to-PC communication via USB[6]. used in USB communication. The demonstration is at
first, press and hold the bootloading button (RB4) and
MPLAB C18 compiler: MPLAB C for PIC18 MCUs, while holding that press reset button. Thereafter, release
publisher microchip, Version 3.47. the reset button and after that release the bootloading
button. The bootloader firmware start to run on PIC
Linker script file: For working with 18F4553 instead of device that means there is a blinking on Led1 and Led2
18F4550 its need some modifications on the MCHPUSB and will be recognized by the PC.
linker script. Open the rm18f4550-MCHPUSB Bootload.l The demonstration and development/verification of
kr file by double clicking on it. Change the line containing the complete USB 2.0 communication solution by using
p18f4550.lib as p18f4553.lib, save the file by ctrl+S. USB device-CDC-BASICDEMO Software in Proteus 7.7
Right click on the workspace containing the codes for the Simulation platform has been completed but continuous
linker file.
ignition in RD0 instead of blinking in RD0 and RD1
alternately. For solving this problem/further investigation
Main program: The main program is a file named main.c
as well as hardware test of the PIC microcontroller-to-PC
contains codes related to the default configuration of the
communication via USB, the PICDEM FS USB Demo
supported devices and their programming environment.
Board (PIC18F4553/PIC18F45K50), Part Number
There are also code protection, watchdog timer, PLL
DM163025-1 is needed.
division etc. Moreover, the file included header files,
The user interface for the USB application in
global variable and function prototype declarations. In the
variables section, 2 char arrays like the USB_In_Buffer PICDEM FS USB Demo Board /Circuit Board, type 5 to
and USB_Out_Buffer, both having character length 64. the textbox next to the button “Send Data” and push
Here, USB_In_Buffer is the array used to send the data to “Send Data”. One will see that the data is (char by char)
PC and USB_Out_Buffer is the one used to receive the incremented by 1 and sent back to PC. Press the button
packages from PC. RB4 and observe the screen “Button Pressed”.
The USB communication has some advantages as
The user interface: The programming environment compared to the other communication protocols (RS232,
chosen to implement the user interface for the USB RS485, parallel communication) such as high bandwidth
application is Microsoft Visual Studio. NET 2005 in transfer, serial communication etc. Moreover, the USB
professional edition. Open the directory C:\Microchip (Universal Serial Bus) is an industry standard that was
Solutions\USB Device-CDC-Basic Demo\PC Software developed to define cables, connectors and protocols for
example\VCsharp 2005\Basic Communication. Run the connection, communication and power supply between
“Csharp Simple CDC Demo” solution file. personal computers and their peripheral devices. And it
has become commonplace on a wide range of devices.
FSUSB framework: After it has been confirmed that USB connectors have replaced other types for battery
accurately implemented the circuit on board, plug it into chargers of portable devices.
77
Int. J. Syst. Signal Control Eng. Appl., 13 (3): 75-78, 2020
78