In collaboration with Microchip, we have built a C library for developers using the MPLAB® Code Configurator. The library supports
- Serial command handler
- Interface Panel
- Maps
- Message Monitor
- Table
- Test Report
- Time Plots
- X-Y Plots
Full details of the library API can be found in the MegunoLink Protocol Library for MPLAB X User Guide.
Requirements
Software
- MPLAB X IDE, verson 5.00 or later
- XC8 Compiler, version 1.45 or later
- MPLAB Code Configurator, version 3.55 or later
Hardware
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
Installation
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:
- Make sure you have installed the latest MPLAB X IDE, XC8 Compiler and the MPLAB Code Configurator.
- Download the MegunoLink library zip file from the Current Download tab of the MPLAB Code Configurator page.
- In the MPLAB X IDE, select Options from the Tools menu to open the Options dialog box.
- Select the Plugins tab, click the Install Library button and select the
MegunoLink_v1.0.0.jar.zip
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.
In the MPLAB X IDE, create a new, standalone project.
- Select File⇒New Project.
- Select Standalone project from the Microchip Embedded category.
- Select the
PICF18857
device, which is found on the X2C+ development board. - Choose the XC8 compiler.
- 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.
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.
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.
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.
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).
Generate library code by clicking the Generate button in the Project Resources section.