We set the HF Internal Clock to 8Mhz and the Clock Divider to 1. We make sure that the selected oscillator is the Internal High-Frequency Oscillator ( HFINTOSC). You may also want to select the proper PIC package in the “ Pin Manager” tab so the microcontroller’s illustration is corresponding to your actual chip. If not we can open it with the “MCC” icon in the toolbar on the top.
The new project gets created and if we have MPLAB’s Code Configurator (MCC) also installed it will get open. Configuring the Microcontroller and its peripherals Also select “ Set as main project” if not already checked and click Finish. Last, the project name and location needs to be filled.
We are going to use the free version in this example.
There is also a payed version of the XC8 compiler which does some more optimization. The XC8 compiler needs to be downloaded and installed separately (see above). By default the IDE comes with a mpasm compiler preinstalled. Next, we need to select a compiler to be used. In our case it will be the “ Curiosity Starter Kit (PKOB)” and click Next.
Optionally we need to select the programmer. In our case it is the “ PIC16F18875” and click Next. Next we select the microcontroller’s family and the concrete device. Select “ Microchip Embedded” category, “ Standalone Project” and click Next. We open the MPLAB X IDE and create a new project: File -> New Project. Now that we have the wiring done let’s go to do some code… Setting up the project The 2 TXO pins will then connect to the LCM1602 IIC module’s SDA and SCK pins. We use the 2 TXI pins of the logic level converter, one for SDA (signal) and the second for SCK (clock) of the I2C of our PIC. We connect both voltages to our Breadboard and connect them to the proper pins of our logic level converter. We feed the development board with 5V from the USB and the board provides PINs for both required voltages (3,3V and 5V). Logical “0” will be in both cases 0V (GND). This means that our logical “1” will be ~3,3V for the PIC and ~5V for the LCD. Our LCD module requires 5V logic and therefore we need a logic level converter from 3V3 to 5V logic. We are going to operate our PIC in 3V3 mode. Those are 8bit mid-range microcontrollers. But it should be possible to adapt to any PIC microcontroller with required peripherals. The presented application may be also reused in other project during development even if the final system will not have any LCD.įor the development the PIC16F18855/75 was chosen since it has most of the peripherals used in our previous projects. This is why we’ve chosen to make the first example with an LCD.
When developing an embedded system one may have the need to have some output, e.g. This may have a couple advantages: custom PCB fitting a certain casing, only used peripherals, much lower power consumption enabling long-term battery powered systems, etc. If one wants to make a step forward and convert his/her prototypes into real product an embedded system comes in mind. Both Adruino and Raspberry come with a ready-made PCB where all those peripherals reside and consume power. This means, e.g., the need to boot for a couple of minutes. In case of Raspberry Pi it is a full-blown computer with all common peripherals, operating system, etc. While Adruino and Raspberry Pi are great prototyping tools allowing fast development of proof of concepts, lot of resources, libraries and examples, it also comes with some pitfalls. We’ve already done some projects with Rasperry Pi.