In the previous tutorial I have designed a PICDUINO board, all the hardware files are shared in that previous article. Today is the day to program this board through the USB port. I have used a PIC18F2550 which is an 8 bit microcontroller similar to an Arduino. It directly supports USB protocol without any interlink chip in between. Which is a great feature of it. Today we will use this feature and program the chip with a blink code. Choosing a blink sketch makes the process easy to learn.
Let me warn you one thing before getting started, that we can not directly use the USB to program the IC, for this we have to first burn the IC with a USB bootloader. Which is basically the same process carried out in the getting started tutorial with PIC kit 3. I will provide all the files, details and programming software links. Because we are new to PIC, I am here to just make the process easier for you.

This PIC series is sponsored by PCBWAY, A reliable and affordable PCB/PCBA manufacturer from CHINA. PCBWAY is one stop solution for all the prototyping needs. As the series continues we will order our development board from PCBWAY.
Project Requirements:
PICKIT 3
PICKIT 3 software : For burning bootloader
Mikrobootloader Software : For Programming through USB
PICDUINO board from PCBWAY
USB type C cable
Uploading the USB Bootloader in PICDUINO:

Download the USB bootloader hex file from here, Connect the PICDUINO with PICKIT 3 using the wired diagram given here. Write the hex file in the program memory of PIC18F2550. To know the full process of writing a hex file to IC, see our getting started with PIC tutorial from here. After successfully writing the bootloader file in the chip now, we can program the chip using USB only. There is no need for PICKIT anymore. Let’s make a hex file of blink code and program it via USB.
Program for Blink in Assembly Language:
void main() { TRISB = 0; // selecting the GPIO as output for(;;) { PORTB = 0XFF; // assigning the value HIGH to GPIO Delay_ms(1000); PORTB = 0; // assigning the value HIGH to GPIO Delay_ms(1000); } }
Now we need a compiler which converts this code (low level language) into machine level code (HEX format) . The proper procedure and software for this is given below. Download the HEX file from here.
Getting Hex file:
For the compiling of the code, and to convert the same into HEX. I am using MikroC Pro software. This one supports the whole family of PIC and is very easy to learn in the first go, if you are a beginner. Let’s convert the code into HEX in 4 steps.
- Download the software, make a new folder and set up a project in that as a standard project.
- Change the CPU clock as per the max clock the IC can work on, see in datasheet
- Go to the edit project section, under the project tools menu. Under the general output setting tick export as hex
- Build the file, It will make some at the project location in the same folder. We only need the Hex file to copy it from there to a safe location. And that is all what we need from the compiler.
Programming Via USB:
Here is the time for Mikrobootloader software, which basically acts as an interpreter for the USB device, and after selecting the HEX file we can directly upload the file. Here is the 5 step process: Download the Mikrobootloader software from here .

Step 1. Establish USB link: Connect your board to your PC. When the device is recognized by your OS the gray USB icon will turn red, indicating that the USB link is successfully established. You have 5s to proceed to the next step. If you wait too long the device will disconnect.
Step 2. Connect with MCU: Click on the Connect button within 5s. The chip automatically enters the Bootloader mode and is ready for further instructions. If your USB link disconnects, just reset the chip to reestablish the link. Then proceed with step 2 again.
Step 3. Choose HEX file: Time to choose blink.hex file, Load the program you want to upload into...
Read more »