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.