Overview
A boot-loader is a computer program that is responsible for booting a computer and booting an operating system. If it also provides an interactive menu with multiple boot choices then it's often called a boot manager.
![]() |
dsPIC30F2010 ds18B20 Demo Program with Boot Loader |
It also applicable for some 8-bit micro-controller with self re-programmable under software control capabilities, for instance the PIC16F877A, PIC16F887, PIC18F4550, dsPIC30F1010, dsPIC30F2010 etc. It's a block of micro-controller program that manage the process of loading embedded program to any location of Flash memory. It must locates at beginning or at the end of micro-controller Flash memory address.
The dsPIC30F2010 is a self re-programmable Flash micro-controller that allow the user to take the advantage of using a boot loader program.
![]() |
Program Space Memory Map for dsPIC30F2010 |
The user just need to burn its boot-loader firmware once using a conventional device programmer, for instance a serial port JDM programmer or even a USB PICKIT3. Then the following embedded program must reserves the boot-loader memory section to prevent ROM program overwriting.
![]() |
Preliminary Boot Loader Firmware Flashing to dsPIC30F2010 |
The boot loader section should locate at the beginning or at the last section of Flash program memory space. However locating it at beginning is very suitable to prevent boot loader program overwriting that can destroy the boot loader functionalities.
A boot-load embedded program can be uploaded to its target MCU an appropriate host PC boot-loader software on any OS platform via a typical serial port or even a USB port. CCS PICC provides a serial port and USB port boot-loader for some of their devices.
CCS PICC PCD Boot Loader Example
Boot Loader for 8-bit PIC Micro-controllers
CCS PICC provide C boot/boot-loader C driver and example for its target chips. For its 8-bit PIC16 and PIC18 chips there are a "bootloader.h" header file and "loader.c" C driver. We can check its "ex_bootloader.c" for boot-loader firmware and "ex_bootload.c" for boot program example. In that example, the boot-loader firmware locates at the beginning of program memory. This example boot the program via RS-232 port.
On the other hand we can use CCS PICC Create Project Wizard to generate a boot-loader firmware for 8-bit PIC micro-controllers. There are two options, boot-loader at the start of memory and boot-loader at the end of memory.
There many method of bootloading the program such as I2C and USB.
Boot Loader for 16-bit PIC Micro-controllers
Since the architecture of 16-bit DSC PIC micro-controllers are far different from the 8-bit PIC micro-controllers, the boot-loader C driver are in separated files. There are two C driver files, the "pcd_bootloader.h" and the "loader_pcd.c" C source files.
There are two C examples file of using the PCD boot-loader firmware. The "ex_pcd_bootloader.c" is firmware of boot-loader prior to boot program. It requires a user input button and reset button to enter firmware loading mode. The "ex_pcd_bootload.c" C sample program is an example of loading the boot program into the chip. It use CCS PICC Serial Input/Output software and boot-loader software to load the program. In this program the boot-loader section locates at the beginning of the program.
Some newer version of CCS PICC as an instance of CCS PICC v5.119 has problem when compiling the boot-loader firmware for some dsPIC30FXXXX series. However I use an older version of CCS PICC v5.049 instead. It works very well without errors and problems.
![]() |
CCS PICC v5.049 IDE |
Boot Loader firmware
Initially I need to prepare a boot-loader firmware for my dsPIC30F2010 DSC.
pcd_bootloader.c
/*CCS PICC Compiler version 5.049*/- #include <30F2010.h>
- #fuses HS,NODEBUG,NOWDT,PR,CKSFSM
- #use delay(clock=20000000)
- #use rs232(BAUD=9600,UART1)
- #define PUSH_BUTTON PIN_C14
- #define BOOT_LED PIN_D0
- #define _bootloader
- //#define BOOTLOADER_MODE2X
- #include <pcd_bootloader.h>
- #include <loader_pcd.c>
- #org APPLICATION_START
- void application(void)
- {
- while(TRUE);
- }
- void main(void)
- {
- output_c(0);
- output_d(0);
- set_tris_d(0);
- set_tris_c(1<<14);
- //set_pullup(TRUE,PUSH_BUTTON);
- output_high(PUSH_BUTTON);
- if(!input(PUSH_BUTTON))
- {
- output_high(BOOT_LED);
- // Let the user know it is ready to accept a download
- printf("\r\nWaiting for download...");
- // Load the program
- load_program();
- }
- output_low(BOOT_LED);
- application();
- while(1);
- }
- #int_default
- void isr(void)
- {
- jump_to_isr(LOADER_END+5);
- }
After compile this program I need to burn its hex file into my target chip using a PICKIT2 device programmer.
![]() |
Preliminary Boot Loader Firmware Flashing to dsPIC30F2010 |
From this point the dsPIC30F2010 has a start-of-memory boot-loader firmware. It doesn't need a device programmer any more. That is a blank program that contain only boot-loader section. To test how it works we just,
1- press and hold the input push button connects to pin RC14
2- at the same time press the reset button and release them.
3- then you will see an LED(pin RD0) turns on the micro-controller enter its loading program mode.
![]() |
The dsPIC30F2010 Prototype Board waiting for program loading |
![]() |
dsPIC30F2010 waiting for loading program from host PC |
Click here to download this example package.
Boot Load Example Program
From here we can load any firmware with a boot loader setting to dsPIC30F2010 via host PC serial port and CCS PICC boot loader software. I modify the "ex_pcd_bootload.c" to blinks an LED then I load it into the dsPIC30F2010 via CCS PICC boot-loader software.
- /*CCS PICC Compiler version 5.049*/
- #include <30F2010.h>
- #fuses HS,NODEBUG,NOWDT,PR,CKSFSM
- #use delay(clock=20M)
- #use rs232(UART1,BAUD=9600)
- //#define BOOTLOADER_MODE2X
- //This is a necessary include file. It reserves space so that the
- //bootloader is not overwritten.
- #include <pcd_bootloader.h>
- #define LED_0 PIN_D1
- print_message(void){
- delay_ms(10);
- printf("\rCCS PICC v5.049 PCD BOOTLOADER\n\r");
- }
- void main()
- {
- print_message();
- unsigned int16 counter=0;
- output_d(0);
- set_tris_d(0);
- while(TRUE)
- {
- output_toggle(LED_0);
- printf("Counter Variable: %Lu\n\r",counter);
- counter++;
- delay_ms(1000);
- }
- }
After compile this program we just press and hold the boot button, and then press and release the reset pin to enter programming loading mode.
Make sure that the SIOW.exe is already open and connected with an appropriate baud rate.
![]() |
press and hold the boot button, and then press and release the reset pin |
![]() |
CCS PICC SIOW Waiting for download |
![]() |
Click on CCS PICC Bootloader tool |
![]() |
Downloading Program |
After the program downloading is completed the application on the MCU will run.
![]() |
Running Program |
Click here to download this example.
ds18B20 LCD Example with Boot-Loader
I modify my program in this post adding a boot-loader program. However it consumes more program memory. I copied the "ds18b20.c" to my project folder since the older version of v5.049 doesn't have this driver.
- pcd_bootload_ds18b20_lcd.c
/*CCS PICC Compiler version 5.049*/- #include <30F2010.h>
- #fuses HS,NODEBUG,NOWDT,PR,CKSFSM
- #use delay(clock=20M)
- #use rs232(UART1,BAUD=9600)
- //#define BOOTLOADER_MODE2X
- //This is a necessary include file. It reserves space so that the
- //bootloader is not overwritten.
- #include <pcd_bootloader.h>
- #define PIN_DS18B20_DATA PIN_B0
- #include "ds18b20.c"
- #define LCD_RS_PIN PIN_E4
- #define LCD_RW_PIN PIN_E5
- #define LCD_ENABLE_PIN PIN_E5
- #define LCD_DATA4 PIN_E0
- #define LCD_DATA5 PIN_E1
- #define LCD_DATA6 PIN_E2
- #define LCD_DATA7 PIN_E3
- #include "lcd.c"
- #define lcd_clear() lcd_putc('\f')
- #define lcd_home() lcd_putc('\a')
- /*For 16x4 LCD Only*/
- #define line_1() lcd_send_byte(0,0x80);
- #define line_2() lcd_send_byte(0,0xC0);
- #define line_3() lcd_send_byte(0,0x90);
- #define line_4() lcd_send_byte(0,0xD0);
- print_message(void){
- delay_ms(10);
- printf("\rCCS PICC v5.049 PCD BOOTLOADER\n\r");
- }
- void main(){
- print_message();
- signed int16 val;
- printf("\n\rdsPIC30F2010 Prototype Board.");
- printf("\n\rSaturday 26th September 2025");
- printf("\n\rds18b20 Humidity Sensor Example\n\r");
- printf("\r\n\r\ds18b20.c - DHT11 example starting\r\n\r\n");
- ds18b20_init();
- lcd_init();
- printf(LCD_PUTC,"dsPIC30F2010 LCD");
- line_2();
- printf(LCD_PUTC,"ds18b20 Sensor");
- line_3();
- printf(LCD_PUTC,"PCD BootLoader");
- line_4();
- printf(LCD_PUTC,"CCS PICC v5.049");
- delay_ms(5000);
- lcd_clear();
- while(1){
- ds18b20_read(&val);
- printf("temperature = %ldC\r\n", val/(signed int16)16);
- lcd_home();
- printf(LCD_PUTC," ds18b20 Sensor");
- line_2();
- printf(LCD_PUTC," Temperature");
- line_3();
- printf(LCD_PUTC," %ld%cC",val/(signed int16)16,0xDF);
- line_4();
- printf(LCD_PUTC," and %f%cF",1.8*(val/(signed int16)16)+32,0xDF);
- delay_ms(1000);
- }
- }
Since the boot-loader section locates at the start of program memory. It doesn't matter even the the compiled boot-load application exceeds the the ROM capacity. It just has an abnormal function.
![]() |
CCS PICC Memory Use |
I tested it on my DIY dsPIC30F2010 Prototype Board.
![]() |
Downloading the program |
After uploading this program we can see the result.
![]() |
Data send over serial port |
This C driver work fine as I prototype it on my PCBA.
![]() |
ds18B20 Temperature Sensor Reading |
Click here to download this example.
DHT-11 LCD Example with Boot-Loader
I add this boot-load feature to my previous programming example that the dsPIC30F2010 read the humidity and temperature data from a DHT-11 environmental sensor. The result will display on a TC1604A-04 16x4 LCM.
- /*CCS PICC Compiler version 5.049*/
- #include <30F2010.h>
- #fuses HS,NODEBUG,NOWDT,PR,CKSFSM
- #use delay(clock=20M)
- #use rs232(UART1,BAUD=9600)
- //#define BOOTLOADER_MODE2X
- //This is a necessary include file. It reserves space so that the
- //bootloader is not overwritten.
- #include <pcd_bootloader.h>
- #define LED_0 PIN_D1
- #define PIN_DHT11_DATA PIN_B0
- #include "dht11.c"
- #define LCD_RS_PIN PIN_E4
- #define LCD_RW_PIN PIN_E5
- #define LCD_ENABLE_PIN PIN_E5
- #define LCD_DATA4 PIN_E0
- #define LCD_DATA5 PIN_E1
- #define LCD_DATA6 PIN_E2
- #define LCD_DATA7 PIN_E3
- #include "lcd.c"
- #define lcd_clear() lcd_putc('\f')
- #define lcd_home() lcd_putc('\a')
- /*For 16x4 LCD Only*/
- #define line_1() lcd_send_byte(0,0x80);
- #define line_2() lcd_send_byte(0,0xC0);
- #define line_3() lcd_send_byte(0,0x90);
- #define line_4() lcd_send_byte(0,0xD0);
- print_message(void){
- delay_ms(10);
- printf("\rCCS PICC v5.049 PCD BOOTLOADER\n\r");
- }
- void main()
- {
- print_message();
- unsigned int8 relativeHumidity;
- unsigned int8 tempC;
- printf("\n\rdsPIC30F2010 Prototype Board.");
- printf("\n\rFriday 26 September 2025");
- printf("\n\rDHT-11 Humidity Sensor Example\n\r");
- printf("\r\n\r\dht-11.c - DHT11 example starting\r\n\r\n");
- dht11_init();
- lcd_init();
- printf(LCD_PUTC,"dsPIC30F2010 LCD");
- line_2();
- printf(LCD_PUTC,"DHT-11 Sensor");
- line_3();
- printf(LCD_PUTC,"PCD BootLoader");
- line_4();
- printf(LCD_PUTC,"CCS PICC v5.049");
- delay_ms(5000);
- lcd_clear();
- while(1){
- dht11_read(&relativeHumidity, &tempC);
- printf("HUMIDITY=%03u%%, TEMPERATURE=%02uC\r\n", relativeHumidity, tempC);
- lcd_home();
- printf(LCD_PUTC," DHT-11 Sensor");
- line_2();
- printf(LCD_PUTC," Reading:");
- line_3();
- printf(LCD_PUTC,"Humidity: %03u%%",relativeHumidity);
- line_4();
- printf(LCD_PUTC,"Temperature:%02u%cC",tempC,0xDF);
- output_toggle(LED_0);
- delay_ms(1000);
- }
- }
The total line of program instructions is less then the previous example (275 instructions).
![]() |
Program Uploading |
The sensor data also send over the PC serial port.
![]() |
CCS PICC SIOW Data Sending |
![]() |
Start-Up Program |
Environmental Data Reading/Displaying
Click here to download this example.