Using Data Monitor and Control Interface with PIC16 MCU

Real time microcontroller applications, such as digital power supplies, motor controllers, and others that utilize one or several real time digital control loops generally can’t be efficiently debugged using LEDs, single-stepping, setting breakpoints, and other traditional programming techniques. In the process of developing a real time system it is often necessary to change a variable on the fly while observing changes in some other variable, also in real time. Microchip MPLAB X and MPLAB IDE have a tool called DMCI (Data Monitor and Control Interface) allowing to do what the name suggests when used in combination with dsPIC and PIC24 micros. I am a big fan of new “enhanced mid range” PIC16 micros and I always wanted to have similar tool to use with these chips. Some time ago I started porting dsPIC RTDM (Real Time Data Monitor, used to communicate with DMCI) protocol implementation to PIC16 and this short article is the announcement of the first working implementation of the protocol.

The title video (expand it to full-screen and switch the resolution to 1080 to see numbers better) demonstrates PIC16F1509 MCU reading its internal fixed voltage reference (FVR). A plot on the right shows, in near real time, last 128 ADC conversions collected into a buffer. A slider on the left allows me to modify sampling delay of the ADC and you can see the difference in conversion when I change this delay from 50 to 20 microseconds. A FVR is high-impedance source and the effect of sampling too fast can be clearly seen. The output is free running, similar to free running oscilloscope timebase; with little extra effort, reads and writes can be synchronized, if desired – see Microchip code examples CE155, CE455 for details.

It should be noted that PIC16 is a very small micro and no amount of clever coding will change that. The RTDM overhead will likely constrain the use of RTDM to test cases rather than real projects. Still, ability to change and read MCU memory on the fly is very useful while testing implementation of digital filters or PID loops.

The C code used to produce the demo along with DMCI config file is available on GitHub. It will run on PIC16F1509 with external 16MHz crystal, other necessary connections being a decoupling capacitor on VCC and a serial connection to a PC running MPLAB X. All software versions are current at the time of writing.

The detailed documentation of RTDM implementation will be posted in several weeks (or so I hope). To increase speed and reduce code size I will be replacing chunks of C code with assembly so if you don’t like assembly, use github commits made earlier than the timestamp of this article. In the mean time, much can be learned from the code itself and developers already familiar with DMCI for dsPIC will have no difficulties using the code as-is.

Please try this code and let me know how it worked for you. Comments can be left in a my Google Plus community or in the “Issues” section of the GitHub repo. You can also use the comment section of the article or by contacting me using one of the e-mails from the “About” section of the site.



7 comments to Using Data Monitor and Control Interface with PIC16 MCU

  • zara

    Hi Mr Oleg

    it’s a very good and efficient job! really!

    sorry but did you use this project with debugger ICD or no ?

    because i have a project with dspic , i enabled the RTDM but the DMCI can’t read at real time .( halt program every time to read ).

    the condition is to use real time ice to run the run-time mode!!

    so is the debugger important?
    so what’s the importance of serial port connection!!

    sorry Mr oleg ,iknow that ur project on mid range?but let me help


    • I know very little about original 16-bit code. I studied it briefly while working on this project but never ran it. Should be easy to port back to 16-bit line though, the only hardware-specific piece is serial driver.

  • zara


    ok thanx Mr Oley for your reply , i will try it and show the result

  • zara

    Hi Mr Oleg

    did you use debugger for this project or no ??

    thanx in advance

  • T Yorky

    Hi there,
    I have used the RTDM on the PIC24/33 for a number of years. I find it absolutely indispensable now. I now have a development utility that operates independently of MPLab/X. This uses RTDM.
    Like your code, MChip did not allow for their poorly adapted protocol. And also the fact that the transmit ‘mechanism’ locks up the cpu waiting to transmit a full message from a buffer.
    I posted a modified version of the RTDM for the PIC24/33 on MChip’s forum. This allows for the delimiters being present in the message data and releases the CPU rather than waiting for the char to be transmitted. You may find this useful for adapting to the PIC16 or PIC18.
    Hope this helps.

  • chrisg

    Is it possible to port an existing Microchip RTDM PICXX implementation over to a different architecture?

    For example, could the it be run on a soft-core processor of an FPGA, but still communicate to the MPlabX RTDM GUI?

    Or is there a technical and/or license limitation that would prevent it?