[[labs.beatcraft.com]]~ [[BC-USB-Kit]]~ #contents * BC-USB-Kit get started [#n36b6741] > This article provides the step-by-step explanations for how to build a firmware form its source code, then how to write the firmware into PIC of BC-USB-Kit.~ When you write your firmware into your BC-USB-Kit, please apply this method.~ ** Requirements [#v90827a2] > To complete the build and writing processes, the hardware and applications are required.~ ~ - BC-USB-Kit~ No pin headers are attached to BC-USB-Kit. There are only hole-throughs. Please solder a DIP-28 connected IC socket and an A/R type L-shaped 6-pin pin header to J1 and J2, respectively.~ &ref(001.png,,20%); &ref(001_Pk.png,,30%);~ ~ - In-Circuit Debugger~ In-circuit Debugger is a tool for writing a firmware into a PIC micro controller. There are two types of In-Circuit Debuggers for PIC: [[MPLAB ICD 3>http://www.microchip.com/Developmenttools/ProductDetails.aspx?PartNO=DV164035]] and [[MPLAB PICkit 3>http://www.microchip.com/Developmenttools/ProductDetails.aspx?PartNO=PG164130]]. In this article, PICkit 3 is used.~ ~ - Firmware (for checking)~ The source code of a demo firmware, “USB Device - CDC - Sensors.zip,” is listed here. It uses the humidity and temperature sensor of BC-USB-Kit.~ #ref(USB Device - CDC - Sensor.zip);~ This firmware can be used for checking the operational status of BC-USB-Kit as well as testing this demo.~ ~ - [[MPLAB X ICD:http://www.microchip.com/pagehandler/en-us/family/mplabx/]]~ This is an IDE for the PIC micro controller. It is used for developing firmwares.~ ~ - [[MPLAB XC Compilers:http://www.microchip.com/pagehandler/en-us/devtools/mplabxc/home.html]] 16bit version (XC16)~ In this article, Windows version of MPLAB X IDE and MPLAB XC Compiler (XC16) are used.~ If you use other platforms other than Windows, please apply the same kinds of tasks, which are explained here.~ ** Build the Firmware [#g863876d] > + Expand the downloaded source code of the firmware, “USB Device - CDC - Sensor.zip.~ + Expand the downloaded source code of the firmware, “USB Device - CDC - Sensor.zip."~ &ref(003_firmware.png,,50%);~ ~ + Start up X IDE.~ &ref(004_X_IDE_launch.png,,50%); &ref(005_X_IDE.png,,20%);~ ~ + From the menu of MPLAB X IDE, select File →Open Project...~ &ref(006_X_IDE_open.png,,20%);~ ~ Open Up “USB Device - CDC – Sensor.X,” which is located at the directory of “USB Device -CDC- Sensor\src\aps\usb\device\cdc_i2c\firmware\.”~ &ref(007_X_IDE_open.png,,20%); &ref(008_X_IDE_open.png,,40%); &ref(009_X_IDE_open.png,,40%);~ ~ + Once open up the project you will use, close Start Page of MPLAB X IDE.~ &ref(010_X_IDE.png,,20%); &ref(011_X_IDE.png,,20%);~ ~ From the menu of MPLAB X IDE, choose Run →Set Project Configuration → Customize.~ &ref(012_X_IDE_conf.png,,20%);~ ~ As the Project Properties Window opens, configure Hardware Tool and Compiler Toolchain for the project. In this project, PICkit 3 is selected for Hardware Tool, and XC16 (v.1.24) is chosen for Compiler Toolchain.~ &ref(013_X_IDE_pp.png,,20%); &ref(014_X_IDE_pp.png,,30%);~ ~ + Once these configurations of Hardware Tool and Compiler Toolchain are completed, select the configuration of Power for PICkit 3. Then, check the box of “Power target circuit form PICkit 3.” This is the end of preparations for building the firmware.~ &ref(015_X_IDE.png,,20%); &ref(016_X_IDE.png,,30%); &ref(017_X_IDE.png,,30%);~ ~ + Once the preparations are completed, to click the icon of Build Project (look at the red circle in the picture) on the window menu of MPLAB X IDE, execute the build process.~ &ref(018_X_IDE_build.png,,30%);~ ~ As the execution log shows up in the tab of USB Device - CDC - Sensor on Output pane, the build process of the firmware is completed.~ &ref(019_X_IDE_build.png,,20%);~ ~ The name of the built firmware is “USB_Device_-_CDC_-_Sensor.X.production.hex, which is located at the directory of “USB Device - CDC - Sensor\src\apps\usb\device\cdc_i2c\firmware\USB Device - CDC – Sensor.X\dist\bc_usbkit_pic24f\production.”~ ** Writing the firmware onto PIC [#n6ebf94a] > + The build process of the firmware is completed, click the icon of Run project (See the red circle in the picture) on the window menu of MPLAB X IDE.~ &ref(020_X_IDE_rp.png,,30%);~ ~ The firmware is written into BC-USB-Kit by PICkit 3.~ While PICkit 3 writes the firmware into PIC, the color of its status LED changes from green to red. As the writing process is completed without any issues, the color of status LED goes back from red to green.~ The status of the writing process is appeared in the PICkit tab on Output pane of the MPLAB X IDE main window.~ &ref(021_X_IDE_rp.png,,20%);~ ~ Programming... Programming/Verify complete When the status shown above appears in the tab, the writing process is successfully finished.~ ~ If you click the icon of Make and Program Device (See the red circle in the picture) on the window menu of MPLAB X IDE, both the build process and the writing process can be completed at once.~ &ref(022_X_IDE_mp.png,,30%);~ ~ - If the writing process is failed, pull off the USB cable of PICkit 3 from the PC once and reconnect the USB cable to the PC. Then, at MPLAB X IDE, show the tab of “USB_Device_-_CDC_-_Sensor – Dashboard” on the left side pane of the main window, and click the icon of “Refresh Debug Tool Status.”~ &ref(027_X_IDE.png,,40%);~ ~ If the color of status LED at PICkit 3 turns to green, it means the system is working correctly.~ Still the writing process is failed, please check the solder work at J2.~ ~ ** Conforming operation of the firmware [#u22163e7] +As BC-USB-Kit, which is the firmware is already written, is connected to a USB port of a PC, driver is installed into the PC, and BC-USB-Kit is recognized as a USB serial port (COM *).~ &ref(023_driver.png,,30%); &ref(024_driver.png,,30%);~ ~ +To open up the recognized COM port by TeraTerm at Baud rate of 9600, the output numbers are displayed.~ &ref(025_teraterm.png,,40%); &ref(026_teraterm.png,,40%);~ ~ The contents of outputs are the read values of the humidity and temperature sensor. These are repeated results of “Temperature x 10: Humidity x 10.”~ * Revision History [#h08d8e05] > - 2015/04/01 This document is initially published.