Microstick for 5V PIC24 K Series Devices Overview The Microstick for 5V PIC24 K Series Devices is designed to provide an easy-to-use, economical development environment for 5V, 16-bit microcontrollers. The board includes an integrated debugger/programmer, a socket for the target microcontroller chip and pins that facilitate insertion into a prototyping board for extremely flexible development. Installing MPLAB IDE and C Compilers The MPLAB Integrated Development Environment (IDE) should be installed prior Americas Asia/Pacific (Continued) to using the Microstick for 5V PIC24 K Series Devices. This board is designed to Atlanta - 678-957-9614 China - Hangzhou - 86-571-2819-3187 run with MPLAB X IDE Version 1.60 or later. While the MPLAB IDE provides Boston - 774-760-0087 China - Hong Kong SAR - 852-2943-5100 Chicago - 630-285-0071 China - Nanjing- 86-25-8473-2460 assembler tools for development, most code examples provided for Microchip Cleveland - 216-447-0464 China - Qingdao - 86-532-8502-7355 devices are written in C language and require a C compiler to be installed. Micro- Dallas - 972-818-7423 China - Shanghai - 86-21-5407-5533 Detroit - 248-538-2250 chips MPLAB XC16 Compiler seamlessly integrates into the MPLAB IDE. Both China - Shenyang - 86-24-2334-2829 Indianapolis - 317-773-8323 China - Shenzhen - 86-755-8864-2200 the MPLAB IDE and XC16 Compiler are free and available for download at: Los Angeles - 949-462-9523 China - Wuhan - 86-27-5980-5300 (1) www.microchip.com/mplabx and www.microchip.com/xc16, respectively. Phoenix - 480-792-7200 China - Xiamen - 86-592-2388138 Santa Clara - 408-961-6444 China - Xian - 86-29-8833-7252 Note 1: MPLAB XC16 Evaluation Version (free) All optimization levels are Toronto - 905-673-0699 China - Zhuhai - 86-756-3210040 enabled for 60 days, then limits to optimization, Level O1. The compiler India - Bangalore - 91-80-3090-4444 Europe will continue to function, but code size may increase. There are no India - New Delhi - 91-11-4160-8631 Austria - Wels - 43-7242-2244-39 India - Pune - 91-20-2566-1512 restrictions on the use of this C compiler (see license text for details). Denmark - Copenhagen - 45-4450-2828 Japan - Osaka - 81-6-6152-7160 France - Paris - 33-1-69-53-63-20 Japan - Tokyo - 81-3-6880-3770 Germany - Munich - 49-89-627-144-0 Korea - Daegu - 82-53-744-4301 Italy - Milan - 39-0331-742611 Running Applications Korea - Seoul - 82-2-554-7200 Netherlands - Drunen - 31-416-690399 Malaysia - Kuala Lumpur - 60-3-6201-9857 Spain - Madrid - 34-91-708-08-90 After downloading and installing the development tools, please use the following Malaysia - Penang - 60-4-227-8870 UK - Wokingham - 44-118-921-5869 Philippines - Manila - 63-2-634-9065 procedure to build, run and debug your software: Asia/Pacific Singapore - 65-6334-8870 1. Open the MPLAB X IDE application and close any open projects. Taiwan - Hsin Chu - 886-3-5778-366 Australia - Sydney - 61-2-9868-6733 Taiwan - Kaohsiung - 886-7-213-7828 China - Beijing - 86-10-8569-7000 2. Open the Microstick application project by navigating to the installation directory Taiwan - Taipei - 886-2-2508-8600 China - Chengdu - 86-28-8665-5511 and selecting the pic24fv16km202 microstick demo.X folder. Thailand - Bangkok - 66-2-694-1351 China - Chongqing - 86-23-8980-9588 3. Connect the Microstick board to the development computer via a USB cable. 4. Open the project properties by selecting File->Project Properties. 2/21/13 5. Ensure the correct device is the selected device in the Device dropdown menu. 6. Select the Microstick from the Hardware Tool. It will be listed under Microchip Starter Kits>Starter Kits (PKOB). 7. Build, program and run the Microstick demo application by selecting Microchip Technology Inc. 2355 West Chandler Blvd. Chandler, AZ 85224-6199 Debug>Debug Project. www.microchip.com 8. Install Jumper, JP1, to enable the on-board LED for RA0 to ensure the The Microchip name and logo, the Microchip logo, and MPLAB are registered trademarks of Microchip program is running. Technology Incorporated in the U.S.A. and other countries. REAL ICE and PICkit are trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. All other trademarks mentioned For more information on building, running and debugging your application, refer to herein are property of their respective companies. 2013, Microchip Technology Incorporated, Printed in the MPLAB IDE Help. the U.S.A. All Rights Reserved. 3/13 DS50002142ADeveloping Applications Hardware Design Microstick for 5V PIC24 K Series Devices only implements circuitry for low-voltage The Microstick for 5V PIC24 K Series Devices is USB bus powered. The device is ICSP programming. To enable low-voltage ICSP programming, it is important to powered directly from the 5V USB bus. Turning power on/off to the target applica- always configure the microcontroller to enable MCLR pin function, rather than RA5 tion is controlled by the MPLAB IDE via the FPF2102 load switch. The FPF2102 general purpose, input pin function. load switch automatically shuts down power to the target if the current exceeds a The following assembly language directive enables the MCLR pin function in the trip point of 200 mA to 400 mA. This may help protect the host PC USB port from device Configuration bits: accidental shorting of power supply pins in the target application circuit. MCLR Pin Enable bit (RA5 input disabled MCLR enabled) The Microstick may be plugged into a prototyping board to develop external appli- config FPOR, MCLRE ON cation circuitry with the PIC MCU. On the bottom side of the board, three rows of In XC16, the same thing is accomplished with this code: pins are provided, labeled P1, P2 and P3. Normally, the Skinny PDIP (SPDIP) lay- out (300 mils) should be used by populating rows, P1 and P2. Optionally, rows, P1 // MCLR Pin Enable bit (RA5 input disabled MCLR enabled) FPOR(MCLRE ON) and P3, may be populated instead to provide a wide PDIP layout (600 mils). The unpopulated, single in-line pin header for soldering into P3 is available separately Warning: Always program the microcontroller with MCLR pin functionality as Digi-Key Part Number ED7464-ND. enabled so that the Microstick for 5V PIC24 K Series Devices can be used to program/debug the chip in the future. If the microcontroller is programmed with MCLR pin function disabled (RA5 input is enabled), the Microstick will no longer pro- gram or debug firmware on the microcontroller because Microstick does not have circuitry to use high-voltage ICSP entry. REAL ICE, MPLAB ICD 3 and PICkit 3 are examples of high-voltage ICSP tools that can be used to recover the part. The slide switch, labeled S3 on the PCB, is used to select which pair of PGECx/ PGEDx pins to use for In-Circuit Serial Programming (ICSP). When moved towards the PDIP socket, the Microstick is set for using PGEC3/PGED3. When moved towards the USB connector, the Microstick is configured for PGEC1/ PGED1. To allow for debugging to work in MPLAB, the devices Configuration bits must be set up to indicate which PGECx/PGEDx pins are actually being used in the circuit. For example, in assembly language, you may need directives such as this: .includep24Fxxxx.in ICD Pin Placement Select (EMUC/EMUD share PGC3/PGD3) config FICD, ICS PGx3 In XC16, the same thing can be accomplished with this code: include <p24Fxxxx.h> // ICD Pin Placement Select (EMUC/EMUD share PGC3/PGD3) FICD(ICS PGx3) An XC16 firmware source code example for blinking the Microsticks LED is provided on the Microchip web site (see