

XC8 is a C compiler from Microchip for 8-bit PICs. MPLAB X a free integrated development (IDE) from Microchip for programming their PIC microcontrollers. This section explains how to get started programming the P-Star in the C language using MPLAB X and XC8. The P-Star can be programmed using standard development tools from Microchip.
Mplab X Compiler Software That Runs
Download and install the latest versions of MPLAB X and XC8. It can be used with Windows, Mac and Linux Operating Systems. MPLAB X IDE is a software that runs on a computer intended to develop applications for Microchip’s Microcontrollers and Digital Signal Controllers.
On the first screen of the New Project wizard, select the “Microchip Embedded” category and then select “Standalone Project”. From the File menu, select “New Project”. Find “MPLAB X IDE” in your Start Menu and run it. Developers who wish to write in the C language will need to download and install a.
In the “File” menu, select “Project Properties”. We need to configure the project’s linker setting to properly account for the P-Star’s bootloader, which takes up the first 8 KB of flash memory. Click “Finish” to create the project. For the Project Name, choose something like “p-star1”, and choose the folder you want it to be in. On the “Select Tool” screen, you can select “PICkit 3” but this choice does not matter because we will not use MPLAB X to the load the program onto the board.

Mplab X Compiler Code Into Main
You should see several instances of warnings similar to “warning: (1311) missing configuration setting for config word 0x300000, using default”. This includes all the command-line arguments passed to XC8 to compile the program, and all the output from the compiler. The “Output” pane should now show the build output from MPLAB X. To compile the code, open the “Production” menu and select “Build Main Project”. Copy and paste the following code into main.c:/* Enable Timer 0 as a 16-bit timer with 1:256 prescaler: sinceThe instruction speed is 12 MHz, this overflows about every 1.4// Blink the green LED with a period of 1.4 s// Blink the yellow LED with a period of 0.7 s// Blink the red LED with a period of 0.35 s Choose a file name like “main” and then click Finish.This should create a new file named “main.c” and open it for editing.

