as “POT,” RC3 as “WAKEHW,” RC4 as
“input2,” and RC5 as “CMD.” Make sure you
name them exactly as shown in Figure 7
because the Custom Name is used in the program. Generate code.
Select the Generate button located next to Project
Resources (Section 2). The MPLABX IDE will then create
all the C language code necessary to implement all the
settings you previously chose.
Write the program.
Above the Project Resources window (Section 2),
select the tab labeled Projects. Looking at Figure 8, select
the “+” beside the project name (Blue) and then the “+”
next to Source. Select main.c. The program listing will
appear in the middle window (Section 4).
Scroll down the program listing to one line under
where it says #include “mcc_generated_files/mcc.h” as
shown in Figure 9. This is where you would enter
the embedded C program that ties all the pieces
together and makes a working project.
The code I wrote to implement the design
goals outlined here is contained in the file Blue
Source code.txt available at the article link.
To implement my code, erase everything
below #include “mcc generated files/mcc.h” and
then copy and paste the contents of Blue Source
code.txt. You can use Windows Notepad to open
and copy the file.
Notice that the program listing has three main
sections: Variables, Functions/Subroutines, followed
by the main program. The main program also has
three parts: SYSTEM_Initialization / interrupts; the
RN4020 setup; and the program loop.
Although there are acceptable variations, I
recommend sticking with this form and order to
minimize confusion. As you will learn when you
complete the embedded C programing tutorial, the
order and position of the program components
matters. Wire the circuit.
Make the connections listed next using
jumpers on the Curiosity board shown in Figure
10. If you’re using the BLE2 click module, just plug
it into the mikroBUS socket; no jumpers are
December 2017 37
1) Curiosity integrated programmer/debugger (eight-bit)
3) BLE2 click
4) RN4020 Bluetooth Low Energy User’s Guide
5) Microchip C programming tutorial
6) Curiosity Development Board User’s Guide
Get Started with MPLABX IDE and Microchip
MPLABX IDE and XC16 compiler
FIGURE 10. Curiosity board wiring.
FIGURE 9. Program listing.