728x90

728x90

Friday, October 3, 2025

dsPIC30F2010 CCS PICC Bootloaders Example

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 CCS PICC Bootloaders Example
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.

dsPIC30F2010 CCS PICC Bootloaders Example
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.  

dsPIC30F2010 CCS PICC Bootloaders Example
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.

dsPIC30F2010 CCS PICC Bootloaders Example
CCS PICC v5.049 IDE

Boot Loader firmware

Initially I need to prepare a boot-loader firmware for my dsPIC30F2010 DSC.

pcd_bootloader.c


  1. /*CCS PICC Compiler version 5.049*/
  2. #include <30F2010.h>
  3. #fuses HS,NODEBUG,NOWDT,PR,CKSFSM
  4. #use delay(clock=20000000)
  5. #use rs232(BAUD=9600,UART1)

  6. #define PUSH_BUTTON PIN_C14
  7. #define BOOT_LED PIN_D0

  8. #define _bootloader
  9. //#define BOOTLOADER_MODE2X

  10. #include <pcd_bootloader.h>
  11. #include <loader_pcd.c>

  12. #org APPLICATION_START
  13. void application(void)
  14. {
  15. while(TRUE);
  16. }

  17. void main(void)
  18. {
  19. output_c(0);
  20. output_d(0);
  21. set_tris_d(0);
  22. set_tris_c(1<<14);
  23. //set_pullup(TRUE,PUSH_BUTTON);
  24. output_high(PUSH_BUTTON);
  25. if(!input(PUSH_BUTTON))
  26. {
  27. output_high(BOOT_LED);
  28. // Let the user know it is ready to accept a download
  29. printf("\r\nWaiting for download...");
  30. // Load the program
  31. load_program();
  32. }
  33. output_low(BOOT_LED);
  34. application();
  35. while(1);
  36. }

  37. #int_default
  38. void isr(void)
  39. {
  40. jump_to_isr(LOADER_END+5);
  41. }


After compile this program I need to burn its hex file into my target chip using a PICKIT2 device programmer.

dsPIC30F2010 CCS PICC Bootloaders Example
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. 

dsPIC30F2010 CCS PICC Bootloaders Example
The dsPIC30F2010 Prototype Board waiting for program loading

 

dsPIC30F2010 CCS PICC Bootloaders Example
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.



  1. /*CCS PICC Compiler version 5.049*/
  2. #include <30F2010.h>
  3. #fuses HS,NODEBUG,NOWDT,PR,CKSFSM
  4. #use delay(clock=20M)
  5. #use rs232(UART1,BAUD=9600)

  6. //#define BOOTLOADER_MODE2X

  7. //This is a necessary include file. It reserves space so that the
  8. //bootloader is not overwritten.
  9. #include <pcd_bootloader.h>

  10. #define LED_0 PIN_D1

  11. print_message(void){
  12. delay_ms(10);
  13. printf("\rCCS PICC v5.049 PCD BOOTLOADER\n\r");
  14. }

  15. void main()
  16. {
  17. print_message();
  18. unsigned int16 counter=0;
  19. output_d(0);
  20. set_tris_d(0);
  21. while(TRUE)
  22. {
  23. output_toggle(LED_0);
  24. printf("Counter Variable: %Lu\n\r",counter);
  25. counter++;
  26. delay_ms(1000);
  27. }
  28. }


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. 


dsPIC30F2010 CCS PICC Bootloaders Example
press and hold the boot button, and then press and release the reset pin

 

dsPIC30F2010 CCS PICC Bootloaders Example
CCS PICC SIOW Waiting for download

 

dsPIC30F2010 CCS PICC Bootloaders Example
Click on CCS PICC Bootloader tool

 

dsPIC30F2010 CCS PICC Bootloaders Example
Downloading Program

After the program downloading is completed the application on the MCU will run.

dsPIC30F2010 CCS PICC Bootloaders Example
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
  

  1. /*CCS PICC Compiler version 5.049*/
  2. #include <30F2010.h>
  3. #fuses HS,NODEBUG,NOWDT,PR,CKSFSM
  4. #use delay(clock=20M)
  5. #use rs232(UART1,BAUD=9600)

  6. //#define BOOTLOADER_MODE2X

  7. //This is a necessary include file. It reserves space so that the
  8. //bootloader is not overwritten.
  9. #include <pcd_bootloader.h>

  10. #define PIN_DS18B20_DATA PIN_B0
  11. #include "ds18b20.c"

  12. #define LCD_RS_PIN PIN_E4
  13. #define LCD_RW_PIN PIN_E5
  14. #define LCD_ENABLE_PIN PIN_E5
  15. #define LCD_DATA4 PIN_E0
  16. #define LCD_DATA5 PIN_E1
  17. #define LCD_DATA6 PIN_E2
  18. #define LCD_DATA7 PIN_E3

  19. #include "lcd.c"

  20. #define lcd_clear() lcd_putc('\f')
  21. #define lcd_home() lcd_putc('\a')
  22. /*For 16x4 LCD Only*/
  23. #define line_1() lcd_send_byte(0,0x80);
  24. #define line_2() lcd_send_byte(0,0xC0);
  25. #define line_3() lcd_send_byte(0,0x90);
  26. #define line_4() lcd_send_byte(0,0xD0);

  27. print_message(void){
  28. delay_ms(10);
  29. printf("\rCCS PICC v5.049 PCD BOOTLOADER\n\r");
  30. }

  31. void main(){
  32. print_message();
  33. signed int16 val;
  34. printf("\n\rdsPIC30F2010 Prototype Board.");
  35. printf("\n\rSaturday 26th September 2025");
  36. printf("\n\rds18b20 Humidity Sensor Example\n\r");
  37. printf("\r\n\r\ds18b20.c - DHT11 example starting\r\n\r\n");
  38. ds18b20_init();
  39. lcd_init();
  40. printf(LCD_PUTC,"dsPIC30F2010 LCD");
  41. line_2();
  42. printf(LCD_PUTC,"ds18b20 Sensor");
  43. line_3();
  44. printf(LCD_PUTC,"PCD BootLoader");
  45. line_4();
  46. printf(LCD_PUTC,"CCS PICC v5.049");
  47. delay_ms(5000);
  48. lcd_clear();
  49. while(1){
  50. ds18b20_read(&val);
  51. printf("temperature = %ldC\r\n", val/(signed int16)16);
  52. lcd_home();
  53. printf(LCD_PUTC," ds18b20 Sensor");
  54. line_2();
  55. printf(LCD_PUTC," Temperature");
  56. line_3();
  57. printf(LCD_PUTC," %ld%cC",val/(signed int16)16,0xDF);
  58. line_4();
  59. printf(LCD_PUTC," and %f%cF",1.8*(val/(signed int16)16)+32,0xDF);
  60. delay_ms(1000);
  61. }
  62. }

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.

dsPIC30F2010 CCS PICC Bootloaders Example
CCS PICC Memory Use


 I tested it on my DIY dsPIC30F2010 Prototype Board.

dsPIC30F2010 CCS PICC Bootloaders Example
Downloading the program

 

After uploading this program we can see the result.

dsPIC30F2010 CCS PICC Bootloaders Example
Data send over serial port

 This C driver work fine as I prototype it on my PCBA.

dsPIC30F2010 CCS PICC Bootloaders Example
dsPIC30F2010 ds18B20 Demo Program with Boot Loader

 
dsPIC30F2010 CCS PICC Bootloaders Example
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. 



  1. /*CCS PICC Compiler version 5.049*/
  2. #include <30F2010.h>
  3. #fuses HS,NODEBUG,NOWDT,PR,CKSFSM
  4. #use delay(clock=20M)
  5. #use rs232(UART1,BAUD=9600)

  6. //#define BOOTLOADER_MODE2X

  7. //This is a necessary include file. It reserves space so that the
  8. //bootloader is not overwritten.
  9. #include <pcd_bootloader.h>

  10. #define LED_0 PIN_D1

  11. #define PIN_DHT11_DATA PIN_B0
  12. #include "dht11.c"
  13. #define LCD_RS_PIN PIN_E4
  14. #define LCD_RW_PIN PIN_E5
  15. #define LCD_ENABLE_PIN PIN_E5
  16. #define LCD_DATA4 PIN_E0
  17. #define LCD_DATA5 PIN_E1
  18. #define LCD_DATA6 PIN_E2
  19. #define LCD_DATA7 PIN_E3

  20. #include "lcd.c"

  21. #define lcd_clear() lcd_putc('\f')
  22. #define lcd_home() lcd_putc('\a')
  23. /*For 16x4 LCD Only*/
  24. #define line_1() lcd_send_byte(0,0x80);
  25. #define line_2() lcd_send_byte(0,0xC0);
  26. #define line_3() lcd_send_byte(0,0x90);
  27. #define line_4() lcd_send_byte(0,0xD0);

  28. print_message(void){
  29. delay_ms(10);
  30. printf("\rCCS PICC v5.049 PCD BOOTLOADER\n\r");
  31. }

  32. void main()
  33. {
  34. print_message();
  35. unsigned int8 relativeHumidity;
  36. unsigned int8 tempC;
  37. printf("\n\rdsPIC30F2010 Prototype Board.");
  38. printf("\n\rFriday 26 September 2025");
  39. printf("\n\rDHT-11 Humidity Sensor Example\n\r");
  40. printf("\r\n\r\dht-11.c - DHT11 example starting\r\n\r\n");
  41. dht11_init();
  42. lcd_init();
  43. printf(LCD_PUTC,"dsPIC30F2010 LCD");
  44. line_2();
  45. printf(LCD_PUTC,"DHT-11 Sensor");
  46. line_3();
  47. printf(LCD_PUTC,"PCD BootLoader");
  48. line_4();
  49. printf(LCD_PUTC,"CCS PICC v5.049");
  50. delay_ms(5000);
  51. lcd_clear();
  52. while(1){
  53. dht11_read(&relativeHumidity, &tempC);
  54. printf("HUMIDITY=%03u%%, TEMPERATURE=%02uC\r\n", relativeHumidity, tempC);
  55. lcd_home();
  56. printf(LCD_PUTC," DHT-11 Sensor");
  57. line_2();
  58. printf(LCD_PUTC," Reading:");
  59. line_3();
  60. printf(LCD_PUTC,"Humidity: %03u%%",relativeHumidity);
  61. line_4();
  62. printf(LCD_PUTC,"Temperature:%02u%cC",tempC,0xDF);
  63. output_toggle(LED_0);
  64. delay_ms(1000);
  65. }
  66. }

 The total line of program instructions is less then the previous example (275 instructions).

M:\ccs picc\v5.049\dsPIC30F2010\pcd_bootload_dht11 - 1604LCD\Media
Program Uploading

 The sensor data also send over the PC serial port.

 

dsPIC30F2010 CCS PICC Bootloaders Example
CCS PICC SIOW Data Sending

dsPIC30F2010 CCS PICC Bootloaders Example
Start-Up Program


dsPIC30F2010 CCS PICC Bootloaders Example
Environmental Data Reading/Displaying

 


Click here to download this example.


Saturday, September 27, 2025

dsPIC30F2010 and ds18B20 Temperature Interfacing

The DS18B20 is a digital thermometer that able to convert the temperature from -55 to +125 degree Celsius. The controller communicates with this temperature sensor using a 1-Wire bus. So this device requires only three wires including GND, VCC, and data line. Furthermore it can use data line to power  the device eliminating the VCC. 

dsPIC30F2010 and ds18B20 Temperature Interfacing

 

This device also work in TTL logic level that could interface with the dsPIC30F2010 using its digital bi-directional I/O. 

PIC16F84A DS18B20 1-Wire Temperature Reading And Multiplexing Display Example Using XC8
DS18B20 Pin Configuration
PIC16F84A DS18B20 1-Wire Temperature Reading And Multiplexing Display Example Using XC8
DS18B20 In TO-92 Package

For more information and interfacing this sensor with a micro-controller please check this post. 

The newer version of CCS PICC (v5.119) have a C driver "ds18b20.c"for this device that allow the programmer to call it using a few lines of code. It's effective and fast.

The following example I use RB0 of dsPIC30F2010 to read the temperature sensor from a single wire ds18b20 temperature sensor. The sensor's data will be send over the RS-232 between the micro-controller and the host PC. I also added a TC1604A-04 16x4 LCD to display the temperature data in degree Celsius and Fahrenheit.  

  • CCS PICC Source Code (v5.119) 

 


  1. /*CCS PICC Compiler version 5.119*/
  2. #include <30F2010.h>
  3. #fuses HS,NODEBUG,NOWDT,PR,CKSFSM
  4. #use delay(clock=20M)
  5. #use rs232(UART1,BAUD=9600)


  6. #define PIN_DS18B20_DATA PIN_B0
  7. #include "ds18b20.c"

  8. #define LCD_RS_PIN PIN_E4
  9. #define LCD_RW_PIN PIN_E5
  10. #define LCD_ENABLE_PIN PIN_E5
  11. #define LCD_DATA4 PIN_E0
  12. #define LCD_DATA5 PIN_E1
  13. #define LCD_DATA6 PIN_E2
  14. #define LCD_DATA7 PIN_E3

  15. #include "lcd.c"

  16. #define lcd_clear() lcd_putc('\f')
  17. #define lcd_home() lcd_putc('\a')
  18. /*For 16x4 LCD Only*/
  19. #define line_1() lcd_send_byte(0,0x80);
  20. #define line_2() lcd_send_byte(0,0xC0);
  21. #define line_3() lcd_send_byte(0,0x90);
  22. #define line_4() lcd_send_byte(0,0xD0);



  23. void main(){
  24. signed int16 val;
  25. printf("\n\rdsPIC30F2010 Prototype Board.");
  26. printf("\n\rSaturday 26th September 2025");
  27. printf("\n\rds18b20 Humidity Sensor Example\n\r");
  28. printf("\r\n\r\ds18b20.c - DHT11 example starting\r\n\r\n");
  29. ds18b20_init();
  30. lcd_init();
  31. printf(LCD_PUTC,"dsPIC30F2010 LCD");
  32. line_2();
  33. printf(LCD_PUTC,"ds18b20 Sensor");
  34. line_3();
  35. printf(LCD_PUTC,"Programming");
  36. line_4();
  37. printf(LCD_PUTC,"CCS PICC v5.049");
  38. delay_ms(5000);
  39. lcd_clear();
  40. while(1){
  41. ds18b20_read(&val);
  42. printf("temperature = %ldC\r\n", val/(signed int16)16);
  43. lcd_home();
  44. printf(LCD_PUTC," ds18b20 Sensor");
  45. line_2();
  46. printf(LCD_PUTC," Temperature");
  47. line_3();
  48. printf(LCD_PUTC," %ld%cC",val/(signed int16)16,0xDF);
  49. line_4();
  50. printf(LCD_PUTC," and %f%cF",1.8*(val/(signed int16)16)+32,0xDF);
  51. delay_ms(1000);
  52. }
  53. }

 I modified the "lcd.c" C driver file to make it works with my TC1604A-04 LCM module. So I need to copy this driver file to my project folder. The "ds18b20.c" C driver file is already existed in the driver folder of CCS PICC v5.119. But I also copied to my project folder.

This program needs 51% of ROM and 36% of RAM.

dsPIC30F2010 and ds18B20 Temperature Interfacing
Serial Input/Output Monitor

I use my DIY dsPIC30F2010 Prototype Board offered by PCBWAY to test this programming example.

dsPIC30F2010 and ds18B20 Temperature Interfacing
Start Up Program

dsPIC30F2010 and ds18B20 Temperature Interfacing
ds18B20 Temperature Reading


Click here to download this example.

 

Friday, September 26, 2025

dsPIC30F2010 and DHT-11 Environmental Sensor Interfacing

The DHT11 temperature and humidity sensor features a temperature and humidity sensor
complex with a calibrated digital signal output. By using the exclusive digital-signal-acquisition
technique and temperature and humidity sensing technology, it ensures high reliability and
excellent long-term stability. This sensor includes a resistive-type humidity measurement
component and an NTC temperature measurement component, and connects to a high performance 8-bit micro-controller, offering excellent quality, fast response, anti-interference
ability and cost-effectiveness.

dsPIC30F2010 and DHT-11 Environmental Sensor Interfacing

Its standard TTL bi-directional I/O suitable for dsPIC30F2010 Interfacing and Programming. It needs only three wires, +5VDC, DATA and GND. Its DATA pin requires a weak pull up resistor with a resistance around 4.7k. 

I use my dsPIC30F2010 DIY Prototype Board to test this program. 

PIC16F84A DHT11 Temperature And Humidity Sensor And Character LCD Interfacing Using XC8
DHT11 Humidity & Temperature
Sensor

Parameters

Relative Humidity
Resolution:             16Bit
Repeatability:         ±1%RH
Accuracy:               25℃ ±5%RH
Interchangeability:  Fully interchangeable
Response time:       1/e (63%)25℃ 6s
                                1m/s Air 6s
Hysteresis:             <±0.3%RH
Long-term stability: <±0.5%RH/yr


Temperature
Resolution:             16Bit
Repeatability:         ±1℃
Accuracy:               25℃ ±2℃
Response time:       1/e (63%) 10S


Electrical Characteristics
Power supply:         DC 3.3~ 5.5V
Supply current:       Measure 0.3mA Standby 60μA
Sampling period:     Secondary Greater than 2 seconds 

For more detail about interfacing this sensor with a micro-controller please see this post. 

dsPIC30F2010 CCS PICC Programming

The newer version of CCS PICC (v5.119) has a C driver for the DHT-11 environmental sensor that could be called using a few lines of code. The "dht11.c" C driver locates in the drivers directory in program files. I use pin RB0 of dsPIC30F2010 to interface with this sensor.

The following example shows a simple sensor reading and data displaying over the RS-232.

  • board.h 
  1. #include <30F2010.h>
  2. #device ICSP=1
  3. #fuses HS,NODEBUG,NOWDT,PR,CKSFSM
  4. #use delay(crystal=20000000)

  5. #define LED0 PIN_D0
  6. #define LED1 PIN_D1
  7. #define SW0 PIN_C13
  8. #define SW1 PIN_C14

  9. #define DELAY 500

  10. #use rs232(UART1, baud=9600, stream=UART_PORT1)

 

  •  main.c
  1. #include "board.h"

  2. #define PIN_DHT11_DATA PIN_B0
  3. #include <dht11.c>

  4. void main(){
  5. unsigned int8 relativeHumidity;
  6. unsigned int8 tempC;
  7. printf("\n\rdsPIC30F2010 Prototype Board.");
  8. printf("\n\rWednesday 25 September 2025");
  9. printf("\n\rDHT-11 Humidity Sensor Example\n\r");
  10. printf("\r\n\r\dht-11.c - DHT11 example starting\r\n\r\n");
  11. dht11_init();
  12. delay_ms(1000);
  13. while(1){
  14. dht11_read(&relativeHumidity, &tempC);
  15. printf("HUMIDITY=%03u%%, TEMPERATURE=%02uC\r\n", relativeHumidity, tempC);
  16. delay_ms(2000);
  17. }
  18. }

 

  • Memory Use 


  •  Serial Input/Output Monitor

 


 
 Click here to download this example.

I add a 16x4 LCD (TC1604A-04) to display temperature and humidity data. Using a character LCD is very conventional for most small micro-controller programming and interfacing. I copied the "lcd.c" 16x2 LCD C driver to my project folder that I can modify it without changing the original file. I disable the LCD R/W pin (wire to GND) and I upgrade this LCD driver to a 16x4 LCD.

Its "board.h" header file remains the same to above example. 

  • main.c

 

  1. #include "board.h"

  2. #define PIN_DHT11_DATA PIN_B0
  3. #include <dht11.c>

  4. #define LCD_RS_PIN PIN_E4
  5. #define LCD_RW_PIN PIN_E5
  6. #define LCD_ENABLE_PIN PIN_E5
  7. #define LCD_DATA4 PIN_E0
  8. #define LCD_DATA5 PIN_E1
  9. #define LCD_DATA6 PIN_E2
  10. #define LCD_DATA7 PIN_E3

  11. #include "lcd.c"

  12. #define lcd_clear() lcd_putc('\f')
  13. #define lcd_home() lcd_putc('\a')
  14. /*For 16x4 LCD Only*/
  15. #define line_1() lcd_send_byte(0,0x80);
  16. #define line_2() lcd_send_byte(0,0xC0);
  17. #define line_3() lcd_send_byte(0,0x90);
  18. #define line_4() lcd_send_byte(0,0xD0);


  19. void main(){
  20. unsigned int8 relativeHumidity;
  21. unsigned int8 tempC;
  22. printf("\n\rdsPIC30F2010 Prototype Board.");
  23. printf("\n\rFriday 26 September 2025");
  24. printf("\n\rDHT-11 Humidity Sensor Example\n\r");
  25. printf("\r\n\r\dht-11.c - DHT11 example starting\r\n\r\n");
  26. dht11_init();
  27. lcd_init();
  28. printf(LCD_PUTC,"dsPIC30F2010 LCD");
  29. line_2();
  30. printf(LCD_PUTC,"DHT-11 Sensor");
  31. line_3();
  32. printf(LCD_PUTC,"Example Using");
  33. line_4();
  34. printf(LCD_PUTC,"CCS PICC v5.119");
  35. delay_ms(5000);
  36. lcd_clear();
  37. while(1){
  38. dht11_read(&relativeHumidity, &tempC);
  39. printf("HUMIDITY=%03u%%, TEMPERATURE=%02uC\r\n", relativeHumidity, tempC);
  40. lcd_home();
  41. printf(LCD_PUTC," DHT-11 Sensor");
  42. line_2();
  43. printf(LCD_PUTC," Reading:");
  44. line_3();
  45. printf(LCD_PUTC,"Humidity: %03u%%",relativeHumidity);
  46. line_4();
  47. printf(LCD_PUTC,"Temperature:%02u%cC",tempC,0xDF);
  48. delay_ms(1000);
  49. }
  50. }

 The TC1604A-04 works fine even it's too old.

dsPIC30F2010 and DHT-11 Environmental Sensor Interfacing
Start-Up Screen


dsPIC30F2010 and DHT-11 Environmental Sensor Interfacing
DHT-11 Sensor Reading and Displaying

Click here to download this example.
 


320x50

Search This Blog

tyro-728x90