M. T. Homer Reid MIT Home Page
Physics Problems Research teaching My Music About Me Miscellany

dspicprg and dspicdmp

Command-Line Utilities for Programming and Dumping Flash Memory in dsPIC Devices

September 3, 2005

Update: Thomas Sailer has added several new features and fixed (at least) one bug in the original code. Tom's version of the software is here. In the meantime, here's a patch Tom submitted to fix the bug he found. This bug causes incorrect behavior when the .hex input file contains data records that straddle memory segment boundaries. (For example, if the .hex file contains a record that starts at address 0x5 and continues through to address 0x15, the unpatched program will behave incorrectly.) Thanks again Tom!

July 31, 2005

Update: Source files have been patched to silence all gcc4 warnings. (Thanks to Thomas Sailer for this patch). Get the patched source archive or just the patch.

January 26, 2005

I have been using the super-convenient JDM programmer hardware and the prog84 console-based software for programming PIC16xx series devices. Both work superbly, but when I recently embarked on a new project involving the dsPIC line of microcontrollers I discovered that they use a different programming protocol not supported by prog84 or any other freeware tools I could find.

Hence these utilities. In their current form they work with the JDM programmer, but the hardware-specific portion of the code is trivial and should be easily tweakable for other programmers. (Note that programmers for PIC16xx series devices, including the JDM programmer, can be made to program dsPIC30F2010 devices with these trivial modifications.)


Usage

Both programs require the -f hexfile option. dspicprg burns the contents of the hex file into the chip, and dspicdmp writes the contents of the chip to the hex file.

norika /home/homer/pic/tuner <>  dspicprg -f tuner.hex
Wrote 160 program words.
Wrote 16 data words.
Wrote 5 configuration words.
Thank you for your support.

norika /home/homer/pic/tuner <>  dspicdmp -f dump.hex
Thank you for your support.

Command-line options for both programs:

Note that dspicprg doesn't do any verifying. Maybe this should be added. For now, to verify you run dspicdmp and compare the resulting output to what you intended to program.


Download

Source archive: dspicprg.tar.gz


Color-Formatted Source Code

Main file for programmer: dspicprg.c
Main file for dumper: dspicdmp.c
Main header file: dspicprg.h
Hardware-specific routines: dspphard.c
STDP programming mode routines: dsppstdp.c
STDP programming sequence definitions: dsppseq.c
STDP programming sequence definitions header file: dsppseq.h
Code/memory packing/unpacking routines: dspppack.c
Routines for working with 'MemoryRow' structures: dsppmrow.c
Routines for reading and writing intel hex files: dspphex.c
Miscellaneous utility routines: dsppmisc.c
Global variable definitions: dsppglob.c


dspicprg and dspicdmp utilities, by Homer Reid
Last Modified: 11/16/16