labs.beatcraft.com
BC-USB-Kit
BC-USB-Kit/Tutorials

Tutorial1

Overview

This document is an introduction of PIC programming. To use BC-USB~Kit, this explains the basics of PIC programming. Please consider this to be kind of PIC Programming 101 or PIC for Dummy.

Lightning up an LED

To follow the great tradition of programming on electronic works (electronic hobby), this article shows how to light up the LED.

Preparation

To read and follow this article,
please install MPLAB X IDE.
   # In this article, MPLAB XIDE v2.35 is installed on Mac OS X (10.10.3).

Creating a new project

Select "New Project" form "File" at the menu bar.
Please select "Microchip Embedded" form "Categories" and “Standalone Project” from "Project."
Then, click the Next button.
TI_00.png

Choose 16-bit MCUs (PIC24) from the pull down menu at Family, and select PIC24FJ128GB202 from the pull down menu at Device. Then, click the Next button.

TI_01.png

Select "PICKit3."
TI_02.png

Choose "X16."
TI_03.png

Type in “LED_Test” at Project Name, and select “UTF-8” at Encoding. Then, click “Finish”
TI_04.png

If “LED_Test” appears on the left pane, the new project is created without any issues.
TI_05.png

To click the right-side button (for Mac OS X, click with the two-finger) on “Source File,” please select “New” from the pop-up menu. Then, choose “C Main File,,,” from the sub-menu.
TI_06.png

Type in “main” at File Name. Then, click the Finish button.
TI_07.png

Then, main.c is added into Source Files.
TI_08.png

Click the hammer (build) icon, Then, if “BUILD SUCCESSFUL,” which are written in green, appears in Output tab at the bottom pane, the build process is succeeded.
TI_09.png

Open “Project Properties” from File at the menu bar.
Select "xc16-gcc" from the list of Categories in the left pane.
At Option categories, select “Preprocessing and message” and add the path of "bc_usbkit_pic24f" to "C include dirs."
TI_11.png

To click the right-side button (for Mac OS X, click with the two-finger) on “Source File,” please select “Add Existing Items form Folders” from the pop-up menu. Then, add "bc_usbkit_pic24f."
If "bc_usbkit_pic24f" is located under Source Files, it is successfully added.
TI_10.png

To include a header file, please add a line of code shown below to main.c.

#include <system.h>

Then, click the icon of a broom on a hammer (Clean and build)
If “BUILD SUCCESSFUL, which are written in green, appears in Output tab at the bottom pane, the build process is succeeded.

Lightning up the LED

As shown in the picture below, please connect BC-USB-Kit with PICKit 3.

# The power of BC-USB-Kit is supplied from the right-side USB port of the MacBook Air.
MBA_and_BC-USB-Kit.jpg

Please add two lines of code shown below to main.c.

SYSTEM_Initialize(SYSTEM_STATE_START);
LED_On(LED_D1);

The contents of main,c file are organized as such as shown below.
TI_12.png

Click the icon of a broom on a hammer (Clean and build).
Then, click the icon of the right faced green triangle (Run Main Project), which is located next to click the icon of a broom on a hammer (Clean and build)

If the LED is lightened in orange, the main project runs successfully.

LED_off.jpg LED_on.jpg

Revision History


Front page   New List of pages Search Recent changes   RSS of recent changes