5 MPLAB® X Users Getting Started
MPLAB X with PIC18F56Q24 Curiosity Nano
Prerequisites
- MPLAB X installed
- The PIC18F56Q24 Curiosity Nano Board is connected to MPLAB X via the on-board USB connector connected to the embedded debugger. The USB powers the kit and the embedded debugger will enable debugging and programming via the USB.
- Microchip University Course: Introduction to MPLAB® X IDE
- Microchip University Course: Overview of the Microchip Code Configurator (MCC)
- Microchip University Course: MPLAB® Data Visualizer (for Curiosity Nano)
Workflow
- Launch MPLAB X.
- The page shown in the figure below will appear when PIC18F56Q24 Curiosity Nano is connected to MPLAB X.
- Start creating a new project by clicking File→New Project or using the <Ctrl+Shift+N> shortcut, as shown in Figure 5-2.
- Select the Categories→Microchip Embedded and Projects→Standalone Project template and click Next.
- Select PIC18F56Q24 and click
Next.
Then select the board and the desired compiler, if there are any.
- Select an available compiler (e.g., XC8 (v.2.45)) and click Finish.
- Type in the name (e.g.,
LED_TOGGLE) and location (e.g.,
C:\
) of the project and click Finish. - Create a new
main.c
file by clicking File→New File or using the <Ctrl+N> shortcut. - Select the Categories→C and File Types→C Main File template, then click Next.
- Type in the file name (e.g.,
main
) and click Finish. - Replace the
main.c
file with the following code snippet:#include <xc.h> int main(void) { PORTF = 0x00; /* Clear PORTA */ LATF = 0x00; /* Clear Data Latch */ ANSELF = 0x00; /* Enable digital drivers */ WPUF = 0x08; /* Enable weak pull-up for SW0 */ TRISF = 0x08; /* Configure SW0 (RF3) as input and LED0 (RF2) pin as output */ while (1) { /* Check the status of SW0 */ /* 0: Pressed */ if (PORTFbits.RF3 == 0) { LATFbits.LATF2 = 0; /* LED0 ON */ } else { LATFbits.LATF2 = 1; /* LED0 OFF */ } } return (EXIT_SUCCESS); }
Add
#include <xc.h>
inmain.c
. In the code editor, the code will appear as shown below. - Build the code by clicking Production→Clean and Build Main Project or using the <Shift+F11> shortcut.
- Program PIC18F56Q24 with the project code and start debugging by clicking Debug→Debugging Main Project.
- Steps 12 and 13 can be accomplished in a single click by using the Debug Main Project option from the toolbar.
- Verify that LED0 is lit when SW0 is pushed on the PIC18F56Q24 Curiosity Nano.