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).

  • Download bc_usbkit_pic24f.zip, and expand the zip file in any directory you wish for.
    To write a program for BC-USB-Kit effortlessly, this file contains the information, which is specifically set up for BC-USB-Kit, including the clock frequency and other default settings and functions for setting the button and LED of BC-USB-Kit.

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

  • 2015-04-22 This article is initially published.

Attach file: filebc_usbkit_pic24f.zip 1135 download [Information] fileLED_on.jpg 1369 download [Information] fileLED_off.jpg 1330 download [Information] fileMBA_and_BC-USB-Kit.jpg 1212 download [Information] fileTI_12.png 1377 download [Information] fileTI_11.png 1325 download [Information] fileTI_10.png 1288 download [Information] fileTI_09.png 1224 download [Information] fileTI_08.png 1375 download [Information] fileTI_07.png 1265 download [Information] fileTI_06.png 1282 download [Information] fileTI_05.png 1314 download [Information] fileTI_04.png 1392 download [Information] fileTI_03.png 1375 download [Information] fileTI_02.png 1288 download [Information] fileTI_01.png 71 download [Information] fileTI_00.png 1520 download [Information]

Front page   Edit Freeze Diff Backup Upload Copy Rename Reload   New List of pages Search Recent changes   RSS of recent changes
Last-modified: 2015-04-20 (Mon) 09:45:57 (3294d)