The release of the clicker 2 for PIC18FK this April has almost gone unnoticed by me. But then I found myself wanting a Clicker2 board that can be programmed in Microchip XC8. And the Clicker 2 for PIC18FK seems a better choice as compared with the older Clicker 2 for PIC18FJ. The PIC18F67K40 microcontroller on board the Clicker 2 for PIC18FK can be configured using MPLAB Code Configurator. The PIC18F87J50 that comes on board the Clicker 2 for PIC18FJ has to be configured at register level – no visual tool to assist us.
So, at first glance, it seems that the Clicker 2 for PIC18FJK is a good candidate for programming in XC8.
Let’s take a closer look at the board:

Same form factor as other Clicker 2 boards, the same design of the power supply and battery circuits. Nothing new here.
On this board, we will find the PIC18F67K40 microcontroller, with a 16MHz oscillator. In a 4x PLL configuration the clock frequency is 64MHz or 16MIPS.
The PIC18F67K40 has 128 KB FLASH program memory with self-read/write capability, 3568 bytes of data SRAM memory and 1024 bytes of EEPROM.
As the PIC18F67K40 has no USB ports, we find here one FT232RL USB-UART chip, connected to the UART4 of the PIC microcontroller.
The Clicker 2 for PIC18FK comes preprogrammed with a UART bootloader. This is different than the usual HID bootloader we will find on other Clicker 2 boards, so we have to download and use the dedicated UART bootloader application.
As an advantage here, with the Clicker 2 for PIC18FK it’s easier to perform UART debugging and to communicate with the PC using a simple terminal application.
Obviously, one can skip the bootloader and program the board using either a PICkit 3, a mikroPROG for PIC, or any other PIC programmer.
Clicker 2 for PIC18FK: programming in XC8
The main reason for ordering this board is to use it with MPLAB Xpress IDE and XC8, especially as the PIC18F67K40 is supported by MPLAB Code Configurator.

To get the 64MHz clock we have to perform the following settings:
- Oscillator Select: EXTOSC with 4xPLL, with EXTOSC operating per FEXTOSC bits
- External clock select: HS (crystal oscillator) above 8MHz; PFM set to high power
- External clock: 16MHz
- Clock divider: 1
- LVP enabled
Then we can configure the microcontroller pins using the Peripheral Pin Select window. In the above example, I’ve only set pin RD7 as an output.
To make the LED connected on the RD7 pin all I had to do is write a few lines of code:
void main(void) { // Initialize the device SYSTEM_Initialize(); while (1) { // Add your application code IO_RD7_SetHigh(); __delay_ms(1000); IO_RD7_SetLow(); __delay_ms(1000); } }
That is, just four lines of code written by me. All I had to do is build the program, and get the .hex file.
And now it comes the nasty surprise: the bootloader doesn’t accept .hex files created by XC8. I don’t know why. The same LED blink written in MikroC PRO for PIC uploads fine. Same clock settings, same pin settings. I don’t know why this happens; I’m still investigating.
However, when uploaded with PICkit 3 or with mikroPROG for PIC, everything works fine.
What about other boards?
Here we see the Clicker2 for PIC18FK and the Clicker2 for PIC18FJ side by side.

Running at 64MHz vs only 48MHz, the Clicker 2 for PIC18FK is a bit faster, achieving 16 MIPS vs the 12MIPS of the PIC18F87J50.
The to click boards have almost the same memory configurations. PIC18F67K40 has 128kb FLASH and 3568 bytes of data memory. PIC18F87J50 also has 128kb FLASH, but it comes with a bigger SRAM, of 3904 bytes.
A major difference is the presence of the USB-UART chip on the Clicker 2 for PIC18FK. In my opinion, this makes for a simpler way to communicate with the PC, using only a simple terminal program. The downside is with a special bootloader, and with the fact that I can’t upload hex files created in XC8.
Of course, I will use an external programmer, but this will offset the advantage brought by using a free IDE. A working bootloader could make this board desirable for someone that is looking for a cheaper way to work with Clicker 2 boards.
Another nice thing is that one can benefit from the whole existing range of mikromedia shields. Adding two more click sockets? There’s a shield that does that. Running on ubiquitous AAA batteries? There’s a shield that does that. Screw terminals, proto shields? There are shields for this.
And, most important, there’s the MikroElektronika Buggy. That is a subject too big to cover here; I will soon post detailed instructions on how to program the Buggy in XC8, with code examples.
Clicker2 for PIC18FK vs. Microchip Curiosity HPC

The only thing the two boards have in common is two mikroBUS sockets. Otherwise, the Curiosity HPC has an onboard programmer, more LEDs, one potentiometer, and the advantage of microcontroller choice.
On the other side, the Clicker2 for PIC18FJ has the advantage of the USB-UART. Furthermore, the Clicker2 for PIC18FJ is more suitable to run on battery power, as it already has all the required hardware.