In collaboration with Microchip, we have built a C library for developers using the MPLAB® Code Configurator. The library supports

Full details of the library API can be found in the MegunoLink Protocol Library for MPLAB X User Guide.




Support for the full range of devices supported by the MPLAB Code Configurator is coming soon. Get in touch and we’ll let you know when the update is ready. In the meantime, you’ll need:

  • PIC16/18
  • Program memory size of at least 28k
  • 1 EUSART/UART module configured


The MegunoLink Protocol Library for MPLAB X is installed using the MPLAB Code Configurator. You’ll find detailed installation instructions in the MegunoLink Protocol Library for MPLAB X User Guide.

Here’s a quick summary:

  1. Make sure you have installed the latest MPLAB X IDE, XC8 Compiler and the MPLAB Code Configurator.
  2. Download the MegunoLink library zip file from the Current Download tab of the MPLAB Code Configurator page.
  3. In the MPLAB X IDE, select Options from the Tools menu to open the Options dialog box.
  4. Select the Plugins tab, click the Install Library button and select the MegunoLink library zip file.

The MPLAB X IDE will confirm the installation succeeded and you are ready to go.

Example walk-through

This simple example sends ADC measurements to be plotted in MegunoLink and turns on an LED in response to serial commands sent from a button on a MegunoLink Interface Panel.

We’ll use the X2C+ development board for this example, but the same steps will work with any PIC that includes a UART.

Check out our getting started guides if you are new to MegunoLink:

X2C+ development board

MegunoLink will work with many PIC micros. The X2C+ development board is a good example.

In the MPLAB X IDE, create a new, standalone project.

  1. Select FileNew Project.
  2. Select Standalone project from the Microchip Embedded category.
  3. Select the PICF18857 device, which is found on the X2C+ development board.
  4. Choose the XC8 compiler.
  5. Give the project a name and click Finish for MPLAB X to create your new project.

Configure your project with the MPLAB Code Configurator.
Select MPLAB Code Configurator from the Tools menu. A configuration file will be created automatically the first time you open the configuration tool, just give it a name.

Add the MegunoLink library to your project by clicking the + icon next to the MegunoLink library in the Device Resources section of the Resource Management [MCC] tab opened by the MPLAB Code Configurator. The Code Configurator will automatically add the library, connect it to the default UART and timer.

Add MPLAB Library

Add the MegunoLink library to your PIC project in the MPLAB X IDE.

We’ll also need an analog-to-digital converter to read the POT, so expand the ADCC node in the Device Resources section and add the ADCC library too.

Add ADC Library

Add the ADC library to your project

Configure the MegunoLink library by selecting it in the Project Resources section of the Resource Management [MCC] tab. You can select the UART, baud rate, timer and visualizers you want to use. Check the All Visualizers button to make all visualizers available to your program.

Configure MegunoLink Library

Select MegunoLink in the Device Resources section to configure the library.

Make sure standard IO (printf(...)) will be sent to the UART by switching to the EUSART tab of the Code Configurator pages. Check the box labelled Redirect STDIO to USART. By default, the MegunoLink library uses printf to send serial data.

Select redirect Std IO

Make sure the Redirect STDIO to USART is selected.

Use the Pin Manager: Grid View to assign:

  • an ADC to pin A0, the output from the discovery board’s POT,
  • four digital outputs on pins C4..C7, the LED pins, and
  • set the serial port to pins C0 (RX) and C1 (TX).
Assign pins

Pin assignments for the X2C+ discovery board.

Generate library code by clicking the Generate button in the Project Resources section.

Generate code

Click the Generate button to create the library code.

Start typing and press Enter to search