Microchip Technology MPLAB Starter Kit User’s Guide

MPLAB Starter Kit
for PIC18F User’s Guide
© 2009 Microchip Technology Inc. DS51852A
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. All of these methods, to our knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
Microchip is willing to work with the customer who is concerned about the integrity of their code.
Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
Information contained in this publication regarding device applications and t he lik e is provided only for your convenience and may be su perseded by upda t es . It is y our responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life supp ort and/or safety ap plications is entir ely at the buyer’s risk, and the buyer agrees to defend, indemnify and hold harmless M icrochip from any and all dama ges, claims, suits, or expenses re sulting from such use. No licens es are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.
Trademarks
The Microchip name and logo, the Microchip logo, dsPIC, K
EELOQ, KEELOQ logo, MPLAB, PIC, PICmicro, PICSTART,
rfPIC and UNI/O are registered trademarks of Microchip Technology Incor porated in the U.S.A. and other countries.
FilterLab, Hampshire, HI-TECH C, Linear Active Thermistor, MXDEV, MXLAB, SEEVAL and The Embedded Control Solutions Company are registered trademarks of Microchip Technology Incorporated in the U.S.A.
Analog-for-the-Digital Age, Application Maestro, CodeGuard, dsPICDEM, dsPICDEM.net, dsPICworks, dsSPEAK, ECAN, ECONOMONITOR, FanSense, HI-TIDE, In-Circuit Serial Programmin g , IC SP, ICEPIC, Mindi, MiW i , MPASM, MPLAB Certified logo, MPLIB, MPLINK, mTouch, nanoWatt XLP, Omniscient Code Generation, PICC, PICC-18, PICkit, PICDEM, PICDEM.net, PICtail, PIC
32
logo, REAL ICE, rfLAB, Select Mode, Total Endurance, TSHARC, WiperLock and ZENA are trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
SQTP is a service mark of Microchip Technology Incorporated in the U.S.A.
All other trademarks mentioned herein are property of their respective companies.
© 2009, Microchip Technology Incorporat ed, Printed in the U.S.A., All Rights Reserved.
Printed on recycled paper.
Microchip received ISO/TS-16949:2002 certification for its worldwide headquarters, design and wafer fabrication facilities in Chandler and Tempe, Arizona; Gresham, Oregon and design centers in California and India. The Company’s quality system processes and procedures are for its PIC devices, Serial EEPROMs, microperipherals, nonvolatile memory and analog products. In addition, Microchip’s quality system for the design and manufacture of development systems is ISO 9001:2000 certified.
®
MCUs and dsPIC® DSCs, KEELOQ
®
code hopping
DS51852A-page ii © 2009 Microchip Technology Inc.
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 Boa rd Set u p ..................... ..................................................................... 7
Chapter 2. The Demonstration Application
2.1 Bootloader From the MicroSD™ Memory Card .............................................9
2.2 USB HID Mouse Demo ................................................................................ 11
2.3 USB HID Joystick Demo .............................................................................. 12
2.4 USB HID Custom Device Demo ................................................................... 13
2.5 USB CDC Demo ...........................................................................................14
2.6 USB MSD Card Reader Demo ...................................................... .. .. ...........14
Chapter 3. Developing an Application
3.1 Setting Up an Example Application for Debug .............................................16
3.2 Running th e E xa mple Applicat io n ............. ............. .. .. .............. .. .. ............. .. . 18
3.3 Debugging the Example Application ............................................................18
3.4 Programming the Debugged Application ........................ .. ............................21
3.5 Creating Other Applications ......................................................................... 21
3.6 Determinin g D ev i ce S u p port ..... ................................................................... 21
3.7 Reserved R e s ou r c e s ............... .. ............. ... .. ................................................. 21
3.8 Debug Vers io n In fo r m a tion .... .. .......................... ... .. ...................................... 21
3.9 Troubleshooting ............................................................................................22
Chapter 4. Hardware
4.1 Application Functional Overview ..................................................................23
4.2 Programmer/Debugger Functional Overview ...............................................24
4.3 Board Components ......................................................................................25
Appendix A. Starter Kit Schematics...........................................................................29
Appendix B. USB Current Draw Requirements.........................................................33
B.1 USB Current Specifications ......................................................................... 33
B.2 PIC18F Sof t S ta r t C ir cu i try ...................................................................... .. .. . 34
B.3 Soft Start Functions and Usage ........................................................... .. ......35
B.4 USB Suspend Current Limitations for the Starter Kit ...................................37
Index .............................................................................................................................39
Worldwide Sales and Service ....................................................................................42
© 2009 Microchip Technology Inc. DS51852A-page iii
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. This number is located on the bottom of each page, in front of the p age number. The numbering convention for the DS number is “DSXXXXXA”, where “XXXXX” is the document number and “A” is the revision level of the document.
For the most up-to-date information on development tools, see the MPLAB Select the Help menu, and then Topics to open a list of available online help files.
INTRODUCTION
®
IDE online help.
This chapter contains general information that will be useful to know before you use the MPLAB Starter Kit for PIC18F. Items discussed in this chapter include:
• Document Layout
• Conventions Used in this Guide
• Warranty Registration
• Recommended Reading
• The Microchip Web Site
• Development Systems Customer Change Notification Service
• Customer Support
• Document Revision History
DOCUMENT LAYOUT
This document describes how to use the starter kit as a development and demonstrative tool for PIC18F J-series device capabilities and features. The manual layout is as follows:
Chapter 1. Introduction to the Starter Kit – This chapter introduces the starter kit and provides an overview of its features.
Chapter 2. The Demonstration Application – This chapter describes the preprogrammed PIC18F demo application.
Chapter 3. Developing an Application – This chapter describes how to debug application software on the starter kit using MPLAB
Chapter 4. Hardware – This chapter provides a functional overview of the starter kit and identifies the major hardware components.
Appendix A. Starter Kit Schematics – This appendix provides detailed schematic diagrams of the starter kit.
Appendix B. USB Current Draw Requirements – This appendix briefly discusses USB current consumption specifications and the methods used by the starter kit to meet those specifications.
®
IDE.
© 2009 Microchip Technology Inc. DS51852A-page 1
MPLAB Starter Kit for PIC18F User’s Guide
CONVENTIONS USED IN THIS GUIDE
This manual uses the following docum entat io n conven tion s:
DOCUMENTATION CONVENTIONS
Description Represents Examples
Arial font:
Italic chara c ters Referenced books MPLAB
Emphasized text ...is the only compiler...
Initial caps A window the Output window
A dialog the Settings dialog A menu selection select Enable Programmer
Quotes A field name in a window or
dialog
Underlined, italic text with right angle bracket
Bold characters A dialog button Click OK
Text in angle brackets < > A key on the keyboard Press <Enter>, <F1>
Courier New font:
Plain Courier New Sample source code #define START
Italic Courier New A variable argument file.o, where file can be
Square brackets [ ] Optional arguments mcc18 [options] file
Curly brackets and pipe character: { | }
Ellipses... Replaces r epeated text
A menu path File>Save
A tab Click the Power tab
Filenames autoexec.bat File paths c:\mcc18\h Keywords _asm, _endasm, static Command-line options -Opa+, -Opa- Bit values 0, 1 Constants 0xFF, ‘A’
Choice of mut ually exclus ive arguments; an OR selection
Represents code supplied by user
®
IDE User’s Guide
“Save project before build”
any valid filename
[options] errorlevel {0|1}
var_name [, var_name...] void main (void)
{ ... }
WARRANTY REGISTRATION
Please complete the enclosed Warranty Registration Card and mail it promptly. Sending in the Warranty Registration Card entitles you to receive new product updates. Interim software releases are available at the Microchip web site.
DS51852A-page 2 © 2009 Microchip Technology Inc.
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 r eference 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. The Readme files contain update information and known issues that may not be included in this user’s guide.
PIC18FJ Device Data Sheets and Flash Programming Specifications
Refer to the appropriate device Data Sheet for device-specific information and specifications. Also, refer to the appropriate device Flash Programming Specification for information on instruction sets and firmware development. These files may be found on the Microchip web site or from your local sales office.
MP ASM™ Assembler, MPLINK™ Object Linker , MPLIB™ Object Librarian User’s Guide (DS33014)
This document discusses the MPLAB ASM Assembler, MPLAB LINK Linker, MPLIB Archiver/Librarian and othe r 8- bit device uti lit ie s, and hel ps you use these tool s in developing applications.
MPLAB
This document helps you use Microchip’s MPLAB C18 C compiler to develop your application.
MPLAB
This document describes how to use the MPLAB IDE (Integrated Development Environment), as well as the MPLAB IDE Project Manager, MPLAB IDE Editor and MPLAB SIM Simulator. Use these development tools to help you develop and debug application code.
®
C18 C Compiler User’s Guide (DS51288)
®
IDE User’s Guide (DS51519)
Preface
© 2009 Microchip Technology Inc. DS51852A-page 3
MPLAB Starter Kit for PIC18F User’s Guide
THE MICROCHI P 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. Accessible by using your favorite Internet browser, the web site contains the following information:
Product Support – Data sheets and errata, application notes and sample programs, design resources, user’s guides and hardware support documents, latest software releases and archived software
General Technical Support – Frequently Asked Questions (FAQs), technical support requests, online discussion groups, Microchip consultant program member listin g
Business of Microchip – Product selector and ordering guides, latest Microchip press releases, listing of seminars and events, listing of Microchip sales offices, distributors and factory representatives
DEVELOPMENT SYSTEMS CUSTOMER CHANGE NOTIFICATION SERVICE
Microchip’s customer notification service helps keep customers current on Microchip products. Subscribers will receive e-mail notification whenever there are changes, updates, revisions or errata related to a specified product family or development tool of interest.
To register, access the Microchip web site at www.microchip.com, click on Customer Change Notification and follow the registration instructions.
The Development Systems product group categories are:
Compilers – The latest information on Microchip C compilers and other language tools. These include the MPLAB C18 and MPLAB C30 C compilers; MPASM™ and MPLAB ASM30 assemblers; MPLINK™ and MPLAB LINK30 object linkers; and MPLIB™ and MPLAB LIB30 object librarians.
In-Circuit Emulators – The latest information on Microchip in-circuit emulators.These include the MPLAB REAL ICE™ and MPLAB ICE 2000 in-circuit emulators.
In-Circuit Debuggers – The latest information on Microchip in-circuit debuggers. These include MPLAB ICD 2 and PICkit™ 2.
MPLAB IDE – The latest information on Microchip MPLAB IDE, the Windows Integrated Development Environment for development systems tools. This list is focused on the MPLAB IDE, MPLAB IDE Project Manager, MPLAB IDE Editor and MPLAB SIM Simulator, as well as general editing and debugging features.
Programmers – The latest information on Microchip programmers. These include the MPLAB PM3 device programmer and the PICSTART 2 development programmers.
®
Plus, and PICkit 1 and
®
DS51852A-page 4 © 2009 Microchip Technology Inc.
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.
Technical support is available through the web site at: http://support.microchip.com
DOCUMENT REVISION HISTORY
Revision A (June 2009)
• Initial Release of this Document
Preface
© 2009 Microchip Technology Inc. DS51852A-page 5
MPLAB Starter Kit for PIC18F User’s Guide
NOTES:
DS51852A-page 6 © 2009 Microchip Technology Inc.

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. Topics covered include:
•Overview
• Operational Requirements
• Initial Board Setup

1.1 OVERVIEW

The MPLAB Starter Kit for PIC18F provides an all-in-one solution for debugging and programming applications using Microchip’s own MPLAB Integrated Development Environment (IDE). A USB connection to a host computer supplies communications and power to the board; no additional external power supply is needed.
The starter kit includes integrated debug and programmer circuitry that allows applications to be programmed onto the application side of the PIC18F MCU and then debugged, all using MPLAB IDE. The need for an additional programmer or hardware interface has been completely eliminated.
The application side of the starter kit contains a range of hardware components to demonstrate the utility and processing power of Microchip’s PIC18F46J50 family USB microcontrollers.
MPLAB STARTER KIT FOR PIC18F
USER’S GUIDE

1.2 OPERATIONAL REQUIREMENTS

To communicate with and program the starter kit, the following hardware and software requirements must be met:
• PC compatible system with CD-ROM drive
• One available USB port on the PC or a powered USB hub
• MicroSD flash memory card (a card preloaded with demo applications is provided)
•Microsoft Note: Only initial testing has been performed on 32-bit Windows Vista for this
®
Windows® 2000 SP4, Windows XP SP2 or Windows Vista® (32-bit)
release of the demo applications. The 64-bit version is not supported at this time.

1.3 INITIAL BOARD SETUP

With its pre-installed demo application, the MPLAB S t arter Kit for PIC18F is designed to be used straight out of the box. Except for a single connection to a computer, no additional hardware or configuration is necessary.
© 2009 Microchip Technology Inc. DS51852A-page 7
MPLAB Starter Kit for PIC18F User’s Guide
A to mini-B USB Cable
Starter Kit
M
MicroSD card

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 S tarter Kit for PIC18F CD firs t. This ensures that both the MPLAB development environment and C compiler , as well as the relevant tutorial and help files for the sta rter kit, are ready to use when the board is connected.
To install the software, insert the starter kit CD into the CD-ROM drive. The installation process starts automatically. The process pauses for user responses to accept the Microchip software licenses and to confirm the installation directories; respond appropriately.

1.3.2 Connecting the Hardware

Once the starter kit software is installed, connect the provided USB cable (A to mini-B) to any available USB port on the PC or powered hub, then to the starter kit at the mini-B receptacle on the application side of the board (on the right side of the board’s lower edge, as shown in Figure 1-1). The PC USB connection provides communication and power to the board. The MicroSD™ Flash card, used to store the demo applications, may be inserted into the MicroSD slot at any time.
If the cable is connected correctly, the green power LED is lit. The OLED display will display the “Microchip PIC18F Starter Kit” main menu. At this point, the application waits for the bootloader Reset switch to be pressed. When it is pressed, the bootloader application is loaded from the MicroSD card and executed. At this point, you can use the “Up” and “Down ” touch p ads to scr oll thro ugh the avail able me nus, and the “Cancel” and “Accept” pads to select me nu it ems. Refer to Chapter 2. “The Demonstration Application” for a complete description of how to use the bootloader application.
When one of the prec omp iled applications is executed, a seq u en ce of po p-u p bal loo n s in the system tray (lower right o f de skt op) sh ou ld app ea r, stating that (1) ne w ha rd wa r e has been found , (2) driv ers are being installe d and (3) th e new har dware is read y for use. If you do not see these messages and the starter kit does not work, try unplugging and reconnecting the USB. If this does not work, refer to Section Chapter 3. “Developing
an Application”.
FIGURE 1-1: STARTER KIT SETUP
DS51852A-page 8 © 2009 Microchip Technology Inc.
MPLAB STARTER KIT FOR PIC18F
Touch Pads and
Scroll Bar
Flash
Program Memory
User
Interface
MDD
File System
HEX File
Parser
OLED
Display
MicroSD™ Flash Card
Firmware

Chapter 2. The Demonstration Application

This chapter descr ib es the pr e co mpile d d em on str at io n ap pl ica ti ons that ar e pr o vid ed with the MPLAB Starter Kit for PIC18F, and how vari ou s fe at u res h igh li gh t t he dev ice’s processing powe r an d ha rdw a re f un ct ion al ity. These include:
• Bootloader from the MicroSD Memory Card
• Interactive Display System (OLED)
• Touch Interface (CTMU)
• USB Device Capabi litie s

2.1 BOOTLOADER FROM THE MicroSD™ MEMORY CARD

The Flash progra m memory of Microchip’ s PIC18F46J50 device is re adable, writable and erasable during normal operation over the entire V ability to perform bootloader operations. T o demonstrate this feature, the MPLAB Starter Kit for PIC18F is pre programmed with a MicroSD bootloade r that gives the ability to load, program and run PIC18 applications from a MicroSD memory card. The bootloader appli­cation extensi vel y use s, and serv es t o de mo ns tra t e, th e Mi croc hip Me mo ry Di sk Dri ve (MDD) file system.
The MicroSD bootlo ader accept s user inputs f rom the touch p ads and scroll ba r, uses the OLED display for user outputs, and uses substantial parts of the Microchip Memory Disk Drive file system to read files and folders from a MicroSD memory card.
Figure 2-1 summarizes the essential firmware design of the bootloader. At system Reset, the MicroSD bootloader checks for a user reque st to run t he bootloa der (by pre ssing the S1 switch within a 10-second window). If this is not the case, the bootloader returns control to the application currently programmed in the microcontroller’s memory.
DD range. This featur e gives user s the
USER’S GUIDE

FIGURE 2-1: FUNCTIONAL BLOCK DIAGRAM OF BOOTLOADER

© 2009 Microchip Technology Inc. DS51852A-page 9
MPLAB Starter Kit for PIC18F User’s Guide
Microchip
PIC18F Starter Kit
Press S1 to load the
SD Bootloader
9
Card not detected!
Please insert a valid
MicroSD card to
continue
>>HIDDEMO CDC_DEMO.HEX
MSD_DEMO.HEX
>>.
.. MOUSE ~1.HEX
JOYSTI~1.HEX
The following demo will be loaded:
Press the R button to accept, or the L button to cancel
CUSTOM~1.HEX
CUSTOM.HEX
Application image
has been loaded. Press the R button to start the application or L button to cancel
file: CUSTOM.HEX
Use ‘up’ and ‘down’
buttons to navigate.
button to select a
Press menu button to
continue
Press the ‘accept’
file.
File is loading.
Please wait.
Mouse Demo v1.0
PIC18F Starter Kit
Press Menu to proceed
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 detect ed by the bootload er, th e MDD file system is i nitialized and th e file struct ure is displayed on th e OLE D. No t e tha t only folders and HEX file s wi ll b e di spl ayed.
The user can press the Up and Down buttons to select a specific file or folder. Pressing the Accept button when a folder is selected causes the bootloader to display the con­tent of that specific folder on the OLED. T o move one level up in the directory hierarchy, either press the Cancel (Left) button, or press the Accept button when the “..” folder is selected.
When a HEX file is selected and the Accept (Right) button is pressed, the MicroSD bootloader will prompt the user for a confirmation to load the file from the MicroSD memory card and program it to the microcontroller’s Flash memory. After this operation is finished, the user may choose to execute that application or to remain in the bootloader.
If the Cancel button is pressed in the root directory, the MicroSD bootloader terminates. The last application programmed into the microcontroller is then executed.
Figure 2-2 shows a typical sequence of OLED messages from the bootloader initialization through the loading of an application (read from top left to bottom right).

FIGURE 2-2: TYPICAL SEQUENCE FOR BOOTLOADER MESSAGES

DS51852A-page 10 © 2009 Microchip Technology Inc.

2.1.1 Memory Organization

The first 40 Kbytes of Flash program memory are used by the MicroSD bootloader. Figure 2-3 shows the memory map of the PIC18F46J50. The application code must ensure that the boot area is not overwritten.

2.1.2 Remapped Vectors

Since the hardware Reset and interrupt vectors lie within the boot area, they are remapped through software to the beginning of the user memory space. Remapping is simply a branch for interrupts; users may observe an additional latency of two instruction cycles to handle interrupts.
Loading...
+ 32 hidden pages