728x90

728x90

Friday, July 25, 2025

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer

Overview

dsPIC30F2010 is a 16-bit Digital Signal Controller from Microchip Technology. This 28-pin PICMicro has a 10-bit ADC module with up to 1MSPS conversion rate. It able to operates up to 30MIPs.

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
PCBWay.com Sponsor PCB Project

 I have two dsPIC30 device that I bought from online store many years now. They have small pin counts and small-size Flash memory suitable for some simple control applications.

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
dsPIC30F2010-20I/SP I have

 I have as SMD adapter for soldering the dsPIC30FF1010-30I/SP for breadboard prototyping. This chip has a high speed ADC.

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
dsPIC30F1010-30I/SO I have

Proteus VSM has a large amount of libraries that is suitable for this simple PCB design.

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
3D Model in Proteus

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
3D Model in Proteus

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
3D Model in Proteus

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
3D Model in Proteus

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
3D Model in Proteus

 
A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
Soldered PCBA

dsPIC30F1010 is 16-bit Digital Signal Controller enhanced for SMPS application. It has a 10-bit ADC module with the conversion speed up to 2000kSPS. It also able to operate up to 20MIPs.

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
A dsPIC30F2010 DIP

 
A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
A dsPIC30F1010 DIP

 

These DIP micro-controllers can easily prototype on a breadboard. However we can create a simple prototype board for these chip from scratch. I designed a prototype board for these chips with a PICKit2 programmer to make it self and easier to prototype.

Circuit Design

I use Proteus VSM to design the schematics for this board. Most of parts are already have in Protues while other parts are downloaded from snapeda website.

I putted some major modules on this board:

  1. PICKit2 programmer
  2. dsPIC30F2010 and dsPIC30F1010 IC socket
  3. RS-232 to TTL converter
  4. ADC inputs
  5. Switches inputs,
  6. LEDs outputs
  7. Male header for external connection

 

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
Schematic Sheet #1


A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
Schematic Sheet #2


A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
Schematic Sheet #3

 I use three A4 size sheet of this design.

PCB Design

Protues PCB design is very easy to use and light weight. It also have a 3D preview tool and Gerber file exporting and viewing tool. 

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
PCB Design in Protues
 

This PCB is approximately 10cmx10cm in size. I use two layers of copper because it is convenience. Furthermore this size of PCB is very low cost to fabricate using any popular PCB manufacturer such as PCBWay

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
Top Copper

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
Bottom Copper

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
Top Silk
 

It's difficult to fabricate this double-side PCB at home using a CNC machine or toner transfer method. This PCB can be fabricate at very low cost by many PCB manufacturers.

PCB Fabrication

I have been using PCBWay for many years now. PCBWay fabricate PCBs at low cost, fast processing time for only 24 hours, and fast delivery time using any carrier options. This double side 10cmx10cm can be fabricate at only 5USD for 5 to 10pcs by PCBWay. It's a standard PCB with silk screen and solder mask.

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
10 PCBs for only 5USD
 

For different size of PCB we can instantly quote on PCBWay website using a zip PCB Gerber file without account.


A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
PCBWay Instant Quote
 

We can accurately see the preview of fabricated PCB generated by the company's online Gerber file viewer.

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
Top Side

 

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
Bottom Side

 

 PCBWay also offer PCBA assembly service at reasonable price.

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
PCBWay PCB Assembly Service


 Click here to download this PCB design

pcbway.com sponsor pcb project august 2025

PIC18F4550 and DSPIC30F2010 PCB fabrication from PCBWay.com


 
A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
A box of two PCB for PIC18F4550 and dsPIC30F2010 Prototype Board sponsored by PCBWay  

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer

A PCB package of 5-pcs


A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
A PCB package of 5-pcs

The PCB processing time is only one day with a few days of delivery time. DHL logistic is preferred by PCBWay and customers.

It's a standard and high quality PCB. Finished PCB needs a surface treatment process to treat them from corrosion. So even we don't solder them instantly its quality is not defected by outside environment. 

For this 5USD PCB order, we can choose different colors of solder mask and silk screen legend as preferred. The standard thickness is 1.6mm that is robust enough for most of application. We can order up to 10 units for only 5USD.

PCB Assembling

PCBWay offers PCB assembling service for a wide range of order with a minimum order of 25 units at a reasonable price. 

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
Soldering PCB Kit

It takes one day to assemble and test this PCBA. The circuit working is correct. Some drill holes have problems so I need to correct it later.



A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
PCBA Top Side

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
PCBA Bottom Side

I tested this PCBA with my PC program to to the PICKit2 device programmer. Everything works well.

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
Power Supply Testing

I test it with PICKit2 on host software. It's error free.
 

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
PICKit2 Software Test

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
PICKit2 Software

I putted a two-row machine-tool female pin header to optionally place a dsPIC30F1010-30I/SO I soldered on an SMD IC adapter board.

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
A dsPIC30F2010-20I/SP and a dsPIC30F1010-30I/SP that could fit on this PCBA
 

I needed to remove dsPIC30F2010 from this PCBA first before placing the dsPIC30F1010 chip.

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
Testing the dsPIC30F1010 on this PCBA

 This chip could programmed with the earlier version of PICKIT programmer, PICKIT2.

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
Testing the dsPIC30F1010-30I/SP with PICKIT2


 Click here to download this PCB design.

If you don't have a USB programmer for the on-board PICKIT2 device programmer. You can use a simple serial port JDM programmer with WINPIC800 PC software. 

 

CCS PICC Sample Code

CCS PICC is very easy to use but we need to pay for license. For beginners with with this embedded C compiler using its project wizard is a good choice.

Using Project 24 Bit Wizard

We can use this wizard for dsPIC30F2010 since it's a 24-bit instruction device. 

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
LED Blinking Using Wizard - Device Settings

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
LED Blinking Using Wizard - Blinking Example


 It will generate source code for us.

  1. #include <main.h>


  2. void main()
  3. {



  4. //Example blinking LED program
  5. while(true)
  6. {
  7. output_low(LED);
  8. delay_ms(DELAY);
  9. output_high(LED);
  10. delay_ms(DELAY);
  11. }

  12. }

 Its main.h file is separated from main.c file.

 

  1. #include <30F2010.h>
  2. #device ICSP=1
  3. #use delay(clock=20000000)

  4. #FUSES NOWDT //No Watch Dog Timer
  5. #FUSES CKSFSM  
  6. //Clock Switching is enabled, fail Safe clock monitor is enabled


  7. #define LED PIN_D0
  8. #define DELAY 1000


In the #use delay directive I have the parameter crystal=20000000 to clock=20000000 to prevent error.

Click here to download this program example. 

On Board LED Blinking

On this PCBA there are two LEDs connects to RD0 and RD1 respectively. So I wrote a simple PIC24 C program to toggle these two LEDs. 

 

  1. #include "board.h"


  2. void main()
  3. {

  4. //Example blinking LED program
  5. while(true)
  6. {
  7. output_low(LED0);
  8. output_high(LED1);
  9. delay_ms(DELAY);
  10. output_high(LED0);
  11. output_low(LED1);
  12. delay_ms(DELAY);
  13. }

  14. }


I also separate its board.h header file as lists below.

  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 DELAY 500


I use its on-board 20MHz crystal oscillator instead of a 10MHz oscillator because I can not use its PLL to get its maximum 20MHz frequency. So this crystal oscillator will directly drive the processor.

Click here to download this sample program. 

Tactile Switches and LEDs

There are two push button connect to RC13 and RC14 of dsPIC30F2010 PCBA respectively. I use software polling from these two switches to toggle two on-board LEDs of RD0 and RD1 respectively. 

  1. #include "board.h"


  2. void main()
  3. {

  4. set_pullup(TRUE,PIN_C13);
  5. set_pullup(TRUE,PIN_C14);


  6. while(TRUE)
  7. {
  8. //TODO: User Code
  9. if(input(SW0)==0){
  10. output_toggle(LED0);
  11. delay_ms(500);
  12. }
  13. if(input(SW1)==0){
  14. output_toggle(LED1);
  15. delay_ms(500);
  16. }
  17. }

  18. }


I also modify its main.h file adding two buttons definition.

  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


I don't use ICD feature due to complexity, and I don't this hardware.

Click here to download this sample program. 

RS-232 To TTL UART Converter

I putted a DB9 COM Port connector on this board for device and host PC communication. However I don't use its standard MAX232 level converter. Instead I use transistor level converter. 

This is a sample program for on-board UART.

  1. #include "board.h"

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

  3. void main()
  4. {
  5. long cnt=0;
  6. printf("HELLO WORLD!\n\r");
  7. printf("Saturady 13 September 2025\n\r");
  8. printf("dsPIC30F2010 DIY Prototype Board.\n\r");
  9. printf("UART To RS-232 Demo Program\n\r");
  10. while(TRUE)
  11. {
  12. //TODO: User Code
  13. printf("Time In Seconds: %Lu \n\r",cnt);
  14. output_toggle(LED0);
  15. cnt++;
  16. delay_ms(1000);
  17. }

  18. }

 The board.h file is the same as above.

  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

It will print the following text. LED connects to RD0 toggle every time the UART send data.


A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
CCS PICC Serial Input Output Monitor

Click here to download this sample program.

Analog to Digital Converter

There are one potentiometer and LM35 temperature sensor on this PCBA. The following C example use the 10-bit ADC module of dsPIC30F2010 to read the ADC value from these two on-board devices.

The following demo program shows a simple ADC reading and sending data over serial port terminal.

  1. #include "board.h"

  2. void main()
  3. {
  4. unsigned int16 adc_value = 0;
  5. float analog=0;
  6. set_pullup(TRUE,PIN_C13);
  7. set_pullup(TRUE,PIN_C14);
  8. output_high(LED0);
  9. setup_adc_ports(sAN4 | sAN5);
  10. setup_adc(ADC_CLOCK_INTERNAL | ADC_TAD_MUL_31);
  11. printf("dsPIC30F2010 CCS PICC ADC and UART Example\n\r");
  12. printf("Using dsPIC30F2010 Prototype Board\n\r");
  13. printf("Wednesday 10-Sept-2025\n\r");
  14. printf("**************************************************\n\r");
  15. delay_ms(100);
  16. while(TRUE)
  17. {
  18. //TODO: User Code
  19. set_adc_channel(4);
  20. delay_us(50);
  21. adc_value = read_adc();
  22. analog = (5.0*adc_value)/1023;
  23. printf("AN4: %4d Decimal %f Volts\n\r",adc_value, analog);
  24. output_toggle(LED0);
  25. set_adc_channel(5);
  26. delay_us(50);
  27. adc_value = read_adc();
  28. analog = (500.0*adc_value)/1023;
  29. printf("AN5: %4d Decimal %f Degree Celsius\n\r",adc_value, analog);
  30. printf("**************************************************\n\r");
  31. output_toggle(LED1);
  32. delay_ms(1000);
  33. }

  34. }

 I put some definition and declaration in the "board.h" header file.

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


  6. #use FIXED_IO( D_outputs=PIN_D1,PIN_D0 )
  7. #use rs232(UART1, baud=9600, stream=UART_PORT1)

  8. #define LED0 PIN_D0
  9. #define LED1 PIN_D1
  10. #define SW0 PIN_C13
  11. #define SW1 PIN_C14

  12. #define DELAY 500

 Two on-board LEDs blink every time the ADC reading and data transmitting completed.

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
on-board ADC reading and data transmission

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
Received data on serial port terminal of CCS PICC IDE

 Click here to download this sample program.

 The HD44780 16x2 Character LCD Interfacing

The Hitachi HD44780 industrial standard alphanumeric LCD interfacing is very interesting for most of novice micro-controller programming. However there are many new replacing controller chip for this device that operate in the same way. They are available in many forms and at very low price.

 

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
A 16x2 HD44780 based LCD

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
A 16x2 HD44780 based LCD

CCS PIC has its own LCD driver library for its C compiler. It works in most of device. Its 4-bit bi-directional interfacing doesn't rely on fixed pin mode. The programmer can select any available micro-controller pins.

  1. #include "board.h"

  2. #define LCD_ENABLE_PIN PIN_E5
  3. #define LCD_RS_PIN PIN_E4
  4. #define LCD_RW_PIN PIN_C14
  5. #define LCD_DATA4 PIN_E0
  6. #define LCD_DATA5 PIN_E1
  7. #define LCD_DATA6 PIN_E2
  8. #define LCD_DATA7 PIN_E3
  9. #include <LCD.C>


  10. void main()
  11. {
  12. long run_time=0;
  13. lcd_init();
  14. lcd_putc("\f");
  15. printf(LCD_PUTC,"HELLO WORLD!\n");
  16. printf(LCD_PUTC,"dsPIC30F2010 LCD");
  17. delay_ms(5000);
  18. lcd_putc("\f");
  19. printf(LCD_PUTC,"CCS PICC\n");
  20. printf(LCD_PUTC,"Example....");
  21. delay_ms(5000);
  22. lcd_putc('\f');
  23. while(TRUE)
  24. {
  25. //TODO: User Code
  26. lcd_putc('\a');
  27. printf(LCD_PUTC,"ON TIME: \n%Lu Seconds",run_time);
  28. run_time++;
  29. delay_ms(1000);
  30. }

  31. }

 

 Its "board.h" header file is the same as above example. Click here to download this sample program.



A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
Start-Up Screen #2

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
Start-Up Screen #1

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
Running Program

Click here to download this sample program. 

Using The TC1604A-04 16x4 LCM Module 

I have a TC1604A-04 (16x4) LCM module that work in almost the same way. It bases on the HD44780 LCD controller but with 4 lines. We can use CCS PICC "lcd.c" C driver to control this module.

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
A TC1604A-04 LCM Module

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
A TC1604A-04 LCM Module
 

It uses the SPLC780D1 controller IC instead of a conventional HD44780 controller chip. 

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
The TC1604A-04 Block Diagram

The original "lcd.c" driver file able to handle only two lines of LCD. To control a four-line LCD module we just add the LCD command.

 

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
TC1604A-04 Display Data RAM (DD RAM)

 We just send the LCD command that's the DDRAM Address of each lines. For instance, the lcd_send_byte(0,0xD0) of "lcd.c" driver set the display line to line 4 of this LCD. I optionally write some macros for new lines and LCD clearance.

 

  1. #include "board.h"

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

  9. #include <LCD.C>

  10. #define line_1() lcd_send_byte(0,0x80);
  11. #define line_2() lcd_send_byte(0,0xC0);
  12. #define line_3() lcd_send_byte(0,0x90);
  13. #define line_4() lcd_send_byte(0,0xD0);
  14. #define lcd_clear() lcd_putc('\f');

  15. void main()
  16. {
  17. long run_time=0;
  18. lcd_init();
  19. lcd_clear();
  20. printf(LCD_PUTC,"dsPIC30F2010 LCD\n");
  21. printf(LCD_PUTC,"20x4 Characters");
  22. line_3();
  23. printf(LCD_PUTC,"Example With");
  24. line_4()
  25. printf(LCD_PUTC,"CCS PICC 5.119");
  26. delay_ms(5000);
  27. lcd_putc('\f');
  28. while(TRUE)
  29. {
  30. //TODO: User Code
  31. lcd_putc('\a');
  32. printf(LCD_PUTC,"ON TIME: \n%Lu Seconds",run_time);
  33. run_time++;
  34. delay_ms(1000);
  35. }

  36. }

 It also depends on the "board.h" header file.

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


  5. #use FIXED_IO( D_outputs=PIN_D1,PIN_D0 )
  6. #use rs232(UART1, baud=9600, stream=UART_PORT1)

  7. #define LED0 PIN_D0
  8. #define LED1 PIN_D1
  9. #define SW0 PIN_C13
  10. #define SW1 PIN_C14

  11. #define DELAY 500


It works fine with my prototype board.

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer



A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer

Click here to download this sample program.

On-board ADC and 16x4 Interfacing

A 16x4 LCD is suitable for reading two ADC channel inputs. I connect this PCBA to an external TC1604A-04 character LCD module to display ADC reading, one is an analog voltage while another is the LM35DZ temperature sensor.

 

  1. #include "board.h"

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

  9. #include <LCD.C>

  10. #define line_1() lcd_send_byte(0,0x80);
  11. #define line_2() lcd_send_byte(0,0xC0);
  12. #define line_3() lcd_send_byte(0,0x90);
  13. #define line_4() lcd_send_byte(0,0xD0);
  14. #define lcd_clear() lcd_putc('\f');

  15. void main()
  16. {
  17. long adc_value = 0;
  18. float analog=0;
  19. lcd_init();
  20. setup_adc_ports(sAN4 | sAN5);
  21. setup_adc(ADC_CLOCK_INTERNAL | ADC_TAD_MUL_31);
  22. lcd_clear();
  23. printf(LCD_PUTC,"dsPIC30F2010 ADC");
  24. line_2();
  25. printf(LCD_PUTC,"and TC1604A-04");
  26. line_3();
  27. printf(LCD_PUTC,"LCD Interfacing");
  28. line_4()
  29. printf(LCD_PUTC,"With CCS PICC");
  30. delay_ms(5000);
  31. lcd_clear();
  32. while(TRUE)
  33. {
  34. //TODO: User Code
  35. line_1();
  36. printf(LCD_PUTC,"ADC Reading(DEC)");
  37. set_adc_channel(4);
  38. delay_us(10);
  39. adc_value = read_adc();
  40. analog = (5.0*adc_value)/1023;
  41. line_2();
  42. printf(LCD_PUTC, "AN4: %4d %fV\n",adc_value, analog);
  43. set_adc_channel(5);
  44. delay_us(10);
  45. adc_value = read_adc();
  46. analog = (5.0*adc_value)/1023;
  47. line_3();
  48. printf(LCD_PUTC, "AN5: %4d %fV",adc_value, analog);
  49. analog = (500.0*adc_value)/1023;
  50. line_4();
  51. printf(LCD_PUTC, "LM35DZ: %f%cC",analog,223);
  52. delay_ms(1000);
  53. }

  54. }

Its "board.h" header file is listed below.

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


  6. #use FIXED_IO( D_outputs=PIN_D1,PIN_D0 )
  7. #use rs232(UART1, baud=9600, stream=UART_PORT1)

  8. #define LED0 PIN_D0
  9. #define LED1 PIN_D1
  10. #define SW0 PIN_C13
  11. #define SW1 PIN_C14

  12. #define DELAY 500


The LM35DZ that I bough was a fake product. The output voltage is not correct.

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
On-board ADC and 16x4 Interfacing


A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
On-board ADC and 16x4 Interfacing
 

Click here to download this sample program. 

Wiring the R/W of LCD to GND 

Using the R/W pin can make the program stuck whenever the LCD has problem, or the LCD is not inserted. However we can connect the LCD R/W pin to GND to send command or data to this character LCD that is most common for most programmer. We don't need to read and wait for LCD respond for polling the LCD busy flag.

So I modify the "lcd.c" C driver to by pass the LCD R/W pin. We just wire this pin to GND. We need to copy the "lcd.c" from "..\Program Files (x86)\PICC\Drivers" to project folder and import it by using the #include "lcd.c" directive.

In project IDE we need to comment out the line while ( bit_test(lcd_read_byte(),7) ) ; and add the delay_us(1000) and delay_us(10) statement. 

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
Modifying the "lcd.c" driver

 The source code is almost the same but the "lcd.c" locates in project folder.

 

  1. #include "board.h"

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

  9. #include "lcd.c"

  10. #define line_1() lcd_send_byte(0,0x80);
  11. #define line_2() lcd_send_byte(0,0xC0);
  12. #define line_3() lcd_send_byte(0,0x90);
  13. #define line_4() lcd_send_byte(0,0xD0);
  14. #define lcd_clear() lcd_putc('\f');

  15. void main()
  16. {
  17. long adc_value = 0;
  18. float analog=0;
  19. lcd_init();
  20. setup_adc_ports(sAN4 | sAN5);
  21. setup_adc(ADC_CLOCK_INTERNAL | ADC_TAD_MUL_31);
  22. lcd_clear();
  23. printf(LCD_PUTC,"dsPIC30F2010 ADC");
  24. line_2();
  25. printf(LCD_PUTC,"and TC1604A-04");
  26. line_3();
  27. printf(LCD_PUTC,"LCD Interfacing");
  28. line_4()
  29. printf(LCD_PUTC,"With CCS PICC");
  30. delay_ms(5000);
  31. lcd_clear();
  32. while(TRUE)
  33. {
  34. //TODO: User Code
  35. line_1();
  36. printf(LCD_PUTC,"ADC Reading(DEC)");
  37. set_adc_channel(4);
  38. delay_us(10);
  39. adc_value = read_adc();
  40. analog = (5.0*adc_value)/1023;
  41. line_2();
  42. printf(LCD_PUTC, "AN4: %4d %fV\n",adc_value, analog);
  43. set_adc_channel(5);
  44. delay_us(10);
  45. adc_value = read_adc();
  46. analog = (5.0*adc_value)/1023;
  47. line_3();
  48. printf(LCD_PUTC, "AN5: %4d %fV",adc_value, analog);
  49. analog = (500.0*adc_value)/1023;
  50. line_4();
  51. printf(LCD_PUTC, "LM35DZ: %f%cC",analog,223);
  52. delay_ms(1000);
  53. }

  54. }

 The firmware operation is OK.

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer

 Click here to download this sample program.



320x50

Search This Blog

tyro-728x90