Microchip Code Configurator: now with support for click boards
MPLAB ®Code Configurator (MCC) is a fantastic tool. One can use the intuitive, graphical interface to configure the peripherals and functions of many microcontrollers — over 300 8-bit PIC16 and PIC18 microcontrollers are supported by the current 1.35 version. I like it a lot, and it’s a perfect tool to configure the new generation of PIC microcontrollers with Peripheral Pin Select (PPS) module — one can forget about configuration registers and such. It’s also a major time saver, I can generate the code routines in a matter of minutes.
And now MCC comes with a new benefit: click board™ support. Yes, code libraries for various click boards from MikroElekctronika will be added directly to MCC. There are over 50 click boards that will be added in the next 50 days, and probably more will follow soon.
The initial release of code libraries supports seven click boards:
With some exception related to the particular schematic of the click board (such as the case of Current click), the code libraries are rather specific to the sensor used and can be easily adapted to work in other configurations. A major time-saver when working with the sensors mentioned above.
So, how does it work? Let’s take a look.
I will start with the latest MPLAB X IDE version 3.55, with XC8 version 1.41 and MCC version 3.26.2.
The release notes provide the following installation instructions:
- Download mikroEClickLibrary_1.0.7.jar from Microchip website.
- In the MPLAB® X IDE, select Options from the Tools menu
- Select Plugins tab
- Click on Add Library
- Add mikroEClickLibrary_v1.0.7.jar
- Restart MPLAB® X IDE (it will ask for restart anyway, so save your work before ou begin the installation process)
The same applies to the Foundation Services library, file foundationServicesLibrary-0.1.14.jar.
If the installation process is OK, in the MCC window we should see the new libraries:
Using the click libraries in MCC
So, I start a new project in MPLAB X IDE, choosing “Microchip Embedded”, “Standalone project”. Then I select the PIC16F18855 microcontroller. I have selected the PICkit3 tool, and XC8 version 1.41. After giving a name to my project, I started MCC.
I performed all the basic settings I usually do when working with the MPLAB Xpress board, then I’ve added the Altitude click library. The MSSP library needed to perform I2C communication is automatically added. All I have to do is click on the “Generate button”.
Simple as that. All the required code is generated by MCC, ready to be used. A quick look into the altitude.c reveals the functions to read temperature and altitude. All I had to do is add the EUSART library, and to redirect STDIO to UART.
Still, I wish to have some pre-made functions to read and write the MPL3115A2 registers, so I can configure the sensor as I wish. The library is quite simple for the given moment.
Even as this is the first time I’m using the library, it took less than 20 minutes to create a working project. Compare this against 1–2 hours of work that were needed to create my own Altitude click example.
Here comes trouble: Alcohol click
After successfully running the Altitude click example, I tried to do the same with the Alcohol click. This click board uses one A/D channel. Well, here is a little issue: the code library assumes a 3.3V reference voltage for ADC. However, some PIC microcontrollers use 5V power (and thus 5V as ADC reference). One has to check this and change 3.3 to 5 inside the code.
MCC, Click libraries and MPLAB Xpress
If you prefer the simpler interface of the MPLAB Xpress, you can still have all the benefits of using the code libraries for MCC. All you need is open MCC, select the code libraries and click the download button. You’ll be able to do the same things that you do in MPLAB X.
Overall, a great addition to the already nice Microchip Code Configurator, and a time-saving option if you work with the sensors on the click boards.
Originally published at https://electronza.com on March 9, 2017. Moved to Medium on May 5, 2020.