MPLAB Starter Kit for PIC18F User’s Guide © 2009 Microchip Technology Inc.
Note the following details of the code protection feature on Microchip devices: • Microchip products meet the specification contained in their particular Microchip Data Sheet. • Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the intended manner and under normal conditions. • There are dishonest and possibly illegal methods used to breach the code protection feature.
MPLAB STARTER KIT FOR PIC18F USER’S GUIDE Table of Contents Preface ........................................................................................................................... 1 Chapter 1. Introduction to the Starter Kit 1.1 Overview ........................................................................................................ 7 1.2 Operational Requirements ............................................................................. 7 1.3 Initial Board Setup .....................
MPLAB Starter Kit for PIC18F User’s Guide NOTES: DS51852A-page iv © 2009 Microchip Technology Inc.
MPLAB STARTER KIT FOR PIC18F USER’S GUIDE Preface NOTICE TO CUSTOMERS All documentation becomes dated, and this manual is no exception. Microchip tools and documentation are constantly evolving to meet customer needs, so some actual dialogs and/or tool descriptions may differ from those in this document. Please refer to our web site (www.microchip.com) to obtain the latest documentation available. Documents are identified with a “DS” number.
MPLAB Starter Kit for PIC18F User’s Guide CONVENTIONS USED IN THIS GUIDE This manual uses the following documentation conventions: DOCUMENTATION CONVENTIONS Description Arial font: Italic characters Represents Examples Referenced books Emphasized text A window A dialog A menu selection A field name in a window or dialog A menu path MPLAB® IDE User’s Guide ...is the only compiler...
Preface RECOMMENDED READING This user’s guide describes how to use the MPLAB Starter Kit for PIC18F. Other useful documents are listed below. The following Microchip documents are available and recommended as supplemental reference resources. Readme Files For the latest information on using other tools, read the tool-specific Readme files in the Readmes subdirectory of the MPLAB IDE installation directory.
MPLAB Starter Kit for PIC18F User’s Guide THE MICROCHIP WEB SITE Microchip provides online support via our web site at www.microchip.com. This web site is used as a means to make files and information easily available to customers.
Preface CUSTOMER SUPPORT Users of Microchip products can receive assistance through several channels: • • • • Distributor or Representative Local Sales Office Field Application Engineer (FAE) Technical Support Customers should contact their distributor, representative or Field Application Engineer (FAE) for support. Local sales offices are also available to help customers. A listing of sales offices and locations is included in the back of this document.
MPLAB Starter Kit for PIC18F User’s Guide NOTES: DS51852A-page 6 © 2009 Microchip Technology Inc.
MPLAB STARTER KIT FOR PIC18F USER’S GUIDE Chapter 1. Introduction to the Starter Kit Thank you for purchasing Microchip Technology’s MPLAB Starter Kit for PIC18F. This board is intended to introduce and demonstrate the capabilities and features of the PIC18F J-series of Flash microcontrollers. In addition, the starter kit has on-board, in-circuit debug circuitry so that you may develop and debug your own applications. This chapter introduces the starter kit and provides an overview of its features.
MPLAB Starter Kit for PIC18F User’s Guide 1.3.1 Installing the Software Before connecting the starter kit to any computer for the first time, it is important to install the accompanying software on the MPLAB Starter Kit for PIC18F CD first. This ensures that both the MPLAB development environment and C compiler, as well as the relevant tutorial and help files for the starter kit, are ready to use when the board is connected. To install the software, insert the starter kit CD into the CD-ROM drive.
MPLAB STARTER KIT FOR PIC18F USER’S GUIDE Chapter 2. The Demonstration Application This chapter describes the precompiled demonstration applications that are provided with the MPLAB Starter Kit for PIC18F, and how various features highlight the device’s processing power and hardware functionality. These include: • • • • 2.
MPLAB Starter Kit for PIC18F User’s Guide When the MicroSD bootloader starts, it initializes the capacitive touch routines and the OLED display. It then monitors for a MicroSD memory card insertion. When an insert event is detected by the bootloader, the MDD file system is initialized and the file structure is displayed on the OLED. Note that only folders and HEX files will be displayed. The user can press the Up and Down buttons to select a specific file or folder.
The Demonstration Application FIGURE 2-3: PROGRAM MEMORY MAP OF THE PIC18F46J50 DEMO 0000h Bootloader Firmware A000h High-Priority Interrupt Vector A008h Low-Priority Interrupt Vector A018h Application Program Memory User Memory Space Reset Vector FFFFh Note: 2.1.3 Memory areas are not shown to scale. Writing Application Code The bootloader operates as a separate entity, which means that an application can be developed with very little concern about what the bootloader is doing.
MPLAB Starter Kit for PIC18F User’s Guide 2.3 USB HID JOYSTICK DEMO This demo uses the starter kit as a USB joystick. To test the joystick feature, open the Game Controller applet in the Control Panel. In the following dialog, select “Joystick Demo” under “Installed Game Controllers”, then click Properties. At the “Joystick Demo properties” dialog, select the Test tab to show the interactive test display (Figure 2-4).
The Demonstration Application 2.4 USB HID CUSTOM DEVICE DEMO The HID Custom Device demo enables generic USB data transfer to and from an attached device. Although the HID class normally is used for interface products, such as keyboards and mice, the HID interface can also be used for other data transfer purposes. The precompiled application provided with the starter kit is meant to be used with the PC application project, HID PnP Demo.exe, provided on the CD-ROM disc that comes with the kit.
MPLAB Starter Kit for PIC18F User’s Guide Note: 2.4.1 The demo PC application is intended to be run under Windows and was written in Microsoft® Visual C++®. If the executable fails to launch correctly, verify that the .NET Framework Version 2.0 (or later) redistributable package has been installed. To verify this, check the list of installed programs in the Control Panel (from the Start button in Windows XP, Settings>Control Panel>Add or Remove Programs). If it is not installed, the .
MPLAB STARTER KIT FOR PIC18F USER’S GUIDE Chapter 3. Developing an Application The MPLAB Starter Kit for PIC18F may be used with MPLAB® IDE, the free integrated development environment available on Microchip’s web site. MPLAB IDE allows the starter kit to be used as an in-circuit debugger, as well as a programmer, for the featured device. In-circuit debugging allows you to run, examine and modify your program for the device embedded in the starter kit hardware.
MPLAB Starter Kit for PIC18F User’s Guide 3.1 SETTING UP AN EXAMPLE APPLICATION FOR DEBUG Once the starter kit software is installed, the on-board debugger must be connected to any available USB port on the PC or powered hub, then to the starter kit at the mini-B receptacle, J2, on the debugger/programmer side of the board (Figure 3-1).
Developing an Application The MPLAB IDE software that is installed on your PC by the starter kit CD-ROM automatically opens an example application that you may use to examine debug features of the starter kit. To prepare the application for debug: 1. Launch MPLAB IDE. The example application project and related workspace will open. For information on projects and workspaces, see the MPLAB IDE documentation mentioned at the beginning of this chapter. 2. Select Project>Build All to build the application code.
MPLAB Starter Kit for PIC18F User’s Guide 3.2 RUNNING THE EXAMPLE APPLICATION The starter kit executes in either real time (Run) or steps (Step Into, Step Over, Animate). Real-time execution occurs when you select Run in MPLAB IDE. Once the device code is halted, either by a Halt or a breakpoint, you can step.
Developing an Application 3.3.1 Editing Application Code To view application code so that it may be edited, do one of the following: • Select Edit>New to create new code or Edit>Open to search for and open an existing code file. • Double-click on a file in the Project window to open an existing code file. See an example Project window in Figure 3-4. FIGURE 3-4: EXAMPLE PROJECT For more information on using the editor to create and edit code, see MPLAB IDE Editor Help. 3.3.
MPLAB Starter Kit for PIC18F User’s Guide FIGURE 3-5: 3.3.3 EXAMPLE BREAKPOINT Using Watch Windows To use a Watch window: • The Watch window is made visible on the desktop by selecting View>Watch. It contains four selectable watch views (via tabs) in which to view variables (SFRs, symbols and absolute addresses). • Select an SFR or symbol from the list and click the related Add button to add it to the Watch window, or click in the “Address” column and enter an absolute address.
Developing an Application 3.4 PROGRAMMING THE DEBUGGED APPLICATION When the program is successfully debugged and running, the next step is to program the device for stand-alone operation in the finished design. When doing this, the resources reserved for debug are released for use by the application. To program the application, use the following steps: 1. Disable the starter kit as a debug tool by selecting Debugger>Select Tool>None. 2.
MPLAB Starter Kit for PIC18F User’s Guide 3.9 TROUBLESHOOTING 3.9.1 Debug Connection Problems While using the starter kit as a debugger, you may get the error, “Unable to Enter Debug Mode”, when programming the device. This can result from communication being lost between the starter kit and MPLAB IDE. To resolve this: 1. Unplug the USB cable from the starter kit. 2. Plug the USB cable back into the starter kit. MPLAB IDE should automatically reconnect to the starter kit.
MPLAB STARTER KIT FOR PIC18F USER’S GUIDE Chapter 4. Hardware This chapter provides a functional overview of the MPLAB Starter Kit for PIC18F, and identifies the major hardware components. Topics covered include: • Application Functional Overview • Programmer/Debugger Functional Overview • Board Components 4.
MPLAB Starter Kit for PIC18F User’s Guide The microcontroller uses one of its A/D Converter channels to sample and convert the potentiometer’s value to a digital value. Four additional A/D channels are used to monitor the directional touch pads of S1. The values from these channels are analyzed with the CTMU to determine when a touch-and-release event occurs on any of the pads. The application firmware determines which action to take based on the application’s current context.
Hardware The debugging and programming side of the starter kit is controlled by a PIC18F67J50 microcontroller running at 48 MHz. The PIC18F67J50’s built-in USB engine provides the communications interface between the starter kit and the host PC. The microcontroller manages debugging or programming of the target PIC18F46J50 by controlling the target’s MCLR, PGC1/EMUC1 and PGD1/EMUD1 signals. Target clocking is provided by the PIC18F67J50.
MPLAB Starter Kit for PIC18F User’s Guide TABLE 4-1: Ref PIC18F STARTER KIT COMPONENT DESCRIPTIONS Debug/Programmer Component Ref Application Component D1 PIC18F67J50 Microcontroller (U1) A1 PIC18F46J50 Microcontroller (U3) D2 mini-B USB Receptacle (J2) A2 OLED Display (LED1) D3 Debugger/Programmer Clock Crystal (Y1) A3 MicroSD™ Card Socket (J5) D4 25LC010A Serial EEPROM (U2) A4 BMA150 Acceleration Sensor (U6) D5 Debug LED (D2) A5 Capacitive Touch Pad (S1) D6 Power LED (D3) A6 min
Hardware A4. BMA150 Acceleration Sensor (U6): This device implements a complete 3-axis accelerometer and temperature sensor solution in an 8-lead QFN package. The accelerometer is a semiconductor-based strain gauge with no moving parts and never requires calibration. All acceleration and temperature data is provided in real time in digital format, compatible with standard SPI interfaces. A5. Capacitive Touch Pads (S1): This 5-element keypad is an integral part of the board’s top layer.
MPLAB Starter Kit for PIC18F User’s Guide NOTES: DS51852A-page 28 © 2009 Microchip Technology Inc.
MPLAB STARTER KIT FOR PIC18F USER’S GUIDE Appendix A. Starter Kit Schematics The following schematic diagrams are included in this appendix: Programmer/Debugger: • Figure A-1: Programmer/Debugger System Application: • Figure A-2: Application Microcontroller, Touch Switches and Associated Components • Figure A-3: OLED Display, LED and Application Side USB Connectors © 2009 Microchip Technology Inc.
MPLAB Starter Kit for PIC18F User’s Guide STARTER KIT SCHEMATIC, SHEET 1: PROGRAMMER/DEBUGGER SYSTEM ICSP™/TEST/DEBUG HEADER FIGURE A-1: DS51852A-page 30 © 2009 Microchip Technology Inc.
Starter Kit Schematics STARTER KIT SCHEMATIC, SHEET 2: APPLICATION MICROCONTROLLER, SOFT START POWER CIRCUIT, ACCELEROMETER AND SWITCHES Not Populated Not Populated Not Populated Not Populated FIGURE A-2: © 2009 Microchip Technology Inc.
MPLAB Starter Kit for PIC18F User’s Guide STARTER KIT SCHEMATIC, SHEET 3: OLED DISPLAY, SD INTERFACE, APPLICATION SIDE USB CONNECTOR AND POWER SUPERVISOR, AND OTHER CONNECTORS DS51852A-page 32 Not Populated (JP1 bridged on Board) MicroSD™ Card Not Populated Not Populated PICkit™ 2 Not Populated FIGURE A-3: © 2009 Microchip Technology Inc.
MPLAB STARTER KIT FOR PIC18F USER’S GUIDE Appendix B. USB Current Draw Requirements This chapter describes the key USB specification current limits and provides a functional overview of the soft start circuitry used by the MPLAB Starter Kit for PIC18F to meet them. The appendix includes the following sections: • • • • B.
MPLAB Starter Kit for PIC18F User’s Guide B.2 PIC18F SOFT START CIRCUITRY One strategy to meet the key USB current specifications is to include a software controllable soft start mechanism. The starter kit implements the simple soft start circuit shown in Figure B-1. FIGURE B-1: PIC18F STARTER KIT SOFT START CIRCUIT +3.3V C16 0.1 μF R21 100k RC0 Q1 IRLML6402PBF R20 1.5k APP_VDD Transistor, Q1, a power MOSFET, blocks the current from the 3.
USB Current Draw Requirements B.3 FIGURE B-2: VARYING PWM OUTPUT TO SLOWLY CROSS THE LINEAR REGION OF Q1’S OUTPUT FIGURE B-3: THE ENTIRE SOFT START PROCESS SOFT START FUNCTIONS AND USAGE A software component on the microcontroller side is also required to manage the PWM output and control the external circuit. The demo applications supplied with the starter kit use three different software function calls to manage USB-related power consumption.
MPLAB Starter Kit for PIC18F User’s Guide B.3.2 AppPowerReady() The AppPowerReady() function returns a BOOL data type that will return TRUE if the soft start is complete or FALSE if it is not. This function should be called periodically during the soft start to insure that the soft start continues ramping properly. If APP_POWER_AUTO_ENABLE is defined, AppPowerReady() will automatically call AppPowerEnable() if it is not already started.
USB Current Draw Requirements B.4 USB SUSPEND CURRENT LIMITATIONS FOR THE STARTER KIT The USB specification limits devices to 2.5 mA of current draw from the bus while a device is in a suspended state. This limit is tested during compliance testing for all USB certified devices. The design of the PIC18F Starter Kit utilizes an on-board debugger.
MPLAB Starter Kit for PIC18F User’s Guide NOTES: DS51852A-page 38 © 2009 Microchip Technology Inc.
MPLAB STARTER KIT FOR PIC18F USER’S GUIDE Index A Acceleration Sensor ......................................11, 12, 24 Application Components Soft Start Circuit................................................ 27 Application Components Acceleration Sensor.......................................... 27 Bootloader Reset Push Button ......................... 27 Capacitive Touch Pad....................................... 27 MicroSD Card Socket ....................................... 26 mini-B USB Receptacle .....
Index T Troubleshooting ....................................................... 22 U Unable to Enter Debug Mode .................................. 22 USB Current Specifications....................................... 33 Suspend Current Limitations ............................ 37 W Warranty Registration ................................................ 2 Watch Window ......................................................... 18 WWW Address...........................................................
Index NOTES: © 2009 Microchip Technology Inc.
WORLDWIDE SALES AND SERVICE AMERICAS ASIA/PACIFIC ASIA/PACIFIC EUROPE Corporate Office 2355 West Chandler Blvd. Chandler, AZ 85224-6199 Tel: 480-792-7200 Fax: 480-792-7277 Technical Support: http://support.microchip.com Web Address: www.microchip.