DV164126 Microchip Technology, DV164126 Datasheet
![KIT DEVELOPMENT USB W/PICKIT 2](/photos/9/4/90430/dv164126_sml.jpg)
DV164126
Specifications of DV164126
Available stocks
Related parts for DV164126
DV164126 Summary of contents
Page 1
... Microchip Technology Inc. Low Pin Count USB Development Kit User’s Guide DS41356A ...
Page 2
... PowerMate, PowerTool, REAL ICE, rfLAB, Select Mode, Total Endurance, 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. ...
Page 3
... Purpose .............................................................................................................. 18 Overview of the HID Mouse Firmware ................................................................ 19 Procedure ........................................................................................................... 20 Testing the Application ....................................................................................... 21 Project Lab 3 (HID Keyboard)........................................................................... 22 Overview of the HID Keyboard Firmware ........................................................... 22 Procedure ........................................................................................................... 24 Testing the Application ....................................................................................... 27 © 2008 Microchip Technology Inc. LOW PIN COUNT USB DEVELOPMENT KIT Table of Contents USER’S GUIDE DS41356A-page iii ...
Page 4
... Low Pin Count USB Development Kit User’s Guide Project Lab 4 (CDC – Serial Emulator)............................................................. 28 Overview of the CDC – Serial Emulator Firmware ..............................................28 Procedure ...........................................................................................................31 Installing Application Drivers ...............................................................................37 Establish Communication ...................................................................................40 Testing the Application ........................................................................................42 Worldwide Sales and Service .....................................................................................48 DS41356A-page iv © 2008 Microchip Technology Inc. ...
Page 5
... The manual layout is as follows: • Chapter 1. “Overview” • Chapter 2. “Getting Started Project Labs” • Appendix A. “Schematics” © 2008 Microchip Technology Inc. LOW PIN COUNT USB DEVELOPMENT KIT Preface NOTICE TO CUSTOMERS USER’ ...
Page 6
... Optional arguments mcc18 [options] file [options] Choice of mutually exclusive errorlevel {0|1} arguments selection Replaces repeated text var_name [, var_name...] Represents code supplied by void main (void) user { ... } © 2008 Microchip Technology Inc. Examples ® IDE User’s Guide ...
Page 7
... Business of Microchip – Product selector and ordering guides, latest Microchip press releases, listing of seminars and events, listings of Microchip sales offices, distributors and factory representatives © 2008 Microchip Technology Inc. Preface ® IDE installation directory. The Readme files DS41356A-page 3 ...
Page 8
... 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 (September 2008) • Initial Release of this Document. DS41356A-page 4 © 2008 Microchip Technology Inc. ...
Page 9
... PIC18F14K50 ICD populated expansion header • (1) CD containing the user guide, course materials and product documentation. • (1) PICkit™ 2 Debugger/Programmer with cable. FIGURE 1-1: © 2008 Microchip Technology Inc. LOW PIN COUNT USB DEVELOPMENT KIT Chapter 1. Overview LOW PIN COUNT USB DEVELOPMENT KIT USER’ ...
Page 10
... J2-J5, J7, J8 are shunted on the bottom side of the board and thus the functions default connected even though no jumper is installed. Cut the jumper to disable the circuitry attached to each pin. DS41356A-page 6 LOW PIN COUNT USB DEVELOPMENT BOARD (Provided by USB regulated 5V to PIC18F14K50 BUS on PIC18F14K50 USB © 2008 Microchip Technology Inc. ...
Page 11
... PIC18F14K50 MCU. Microchip’s USB Device Firmware Framework is introduced as a resource providing a library of firmware code for USB operation that handles “low-level” tasks and a number of reference projects. The user is guided through a number of “hands-on” labs to reinforce covered concepts. © 2008 Microchip Technology Inc. PIC18F14K50 POPULATED MPLAB ICD 2 DEBUG HEADER DS41356A-page 7 ...
Page 12
... Low Pin Count USB Development Kit User’s Guide NOTES: DS41356A-page 8 © 2008 Microchip Technology Inc. ...
Page 13
... In order to complete the Project Labs, the user should have: 1. The most current version of the MPLAB IDE and C18 compiler installed on their PC. 2. The most current version of the PICkit 2 programmer software. © 2008 Microchip Technology Inc. LOW PIN COUNT USB DEVELOPMENT KIT USER’S GUIDE ...
Page 14
... Once in the MPLAB IDE, start the Project Wizard by selecting Project>Project Wizard 3. Select the PIC18F14K50 as the device, select the MPLAB C18 C Compiler as the language toolsuite, and create a new project folder in the following directory: C:\Microchip Solutions\Project Lab 1\Project Lab 1 DS41356A-page 10 http://www.microchip.com/stellent/idcplg?IdcSer- © 2008 Microchip Technology Inc. ...
Page 15
... C:\Microchip Solutions\Microchip\Usb\HID Device Driver to copy the HID specific source file: a) usb_function_hid.c 9. Finally, navigate to C:\MCC18\lkr and copy the 18f14k20.lkr linker file. 10. Click Next>Next to exit the project wizard. The Project window should now resemble Figure 2-1. © 2008 Microchip Technology Inc. DS41356A-page 11 ...
Page 16
... OK to add to the directory. Repeat these steps to add the application folder C:\LPCUSBDK_Labs\Lab1_files. 14. Ensure that the Library Search Path points to the “lib” directory and the Linker-Script Path points to “lkr” directory both in the C:\MCC18 folder. DS41356A-page 12 PROJECT WINDOW FOR LAB 1 © 2008 Microchip Technology Inc. ...
Page 17
... In the MPLAB IDE Project window, select and open the usb_descriptors.c source file. Note #include "./USB/usb_function_hid.h" at the top of the file different class of device is being defined for a given application, the appropriate class header file will need to be included here. © 2008 Microchip Technology Inc. CONFIGURING FOR MICROCHIP USB FIRMWARE FRAMEWORK DS41356A-page 13 ...
Page 18
... USB Spec Release Number in BCD format // Class Code // Subclass code // Protocol code // Max packet size for EP0, see // usbcfg.h // Vendor ID // Product ID // Device release number in BCD format // Manufacturer string index // Product string index // Device serial number string index // Number of possible configurations © 2008 Microchip Technology Inc. ...
Page 19
... Edit>Find in Files in the MPLAB IDE. This will locate all instances of the definition within the project and list them in the Output window. © 2008 Microchip Technology Inc. CONFIGURATION, CLASS SPECIFIC AND INTERFACE // Size of this descriptor in bytes ...
Page 20
... Scroll down to the report descriptor section and copy and paste the code in Example 2-5 between the curly brackets in the section labeled: //ADD REPORT DESCRIPTOR CODE HERE DS41356A-page 16 MANUFACTURER STRING DESCRIPTOR FOR LAB 1 PRODUCT STRING DESCRIPTOR FOR LAB 1 © 2008 Microchip Technology Inc. ...
Page 21
... Enumeration Demo” text placed in the product string earlier in this lab. © 2008 Microchip Technology Inc. REPORT DESCRIPTOR FOR LAB 1 Usage Page (Generic Desktop)*/ ...
Page 22
... The source code developed here is an exact replica of the USB Device - HID – Mouse application found in the Framework. C:\Microchip Solutions\USB Device - HID - Mouse\HID - Mouse – Firmware The user is encouraged to use these files as a reference when needed. DS41356A-page 18 DEVICE MANAGER WINDOW AND HID DRIVERS INSTALLED © 2008 Microchip Technology Inc. ...
Page 23
... Each element of the array is accessed by incrementing the vector variable counter. The buffer array is then loaded into a hid_report_in[] buffer array that is used by the HIDTxPacket macro to transmit the data along the USB to the Host PC. © 2008 Microchip Technology Inc. FLOWCHART FOR THE EMULATE_MOUSE() YES ...
Page 24
... Scroll down to the ProcessIO() function. Note the pushbutton check that toggles the emulate_mode flag. Uncomment the code: //emulate_mode = !emulate_mode; 7. Finally, scroll down to the Emulate_Mouse function and insert the code in Example 2-7 between the curly brackets in the section marked: //ADD EMULATE MOUSE CODE HERE DS41356A-page 20 © 2008 Microchip Technology Inc. ...
Page 25
... Host PC screen. The user is encouraged to experiment with this application by altering the length of time that the mouse pointer moves until a directional change or altering the values in the ROM signed char dir_table[]={-4,-4,- 0}; © 2008 Microchip Technology Inc. USER DEFINED FUNCTIONAL CODE FOR EMULATE_MOUSE() DS41356A-page 21 ...
Page 26
... ADC module, transmit the numeric value along the USB and display the appropriate character on the screen. This function is implemented as a state machine. The state diagram for this function is shown in Figure 2-4. DS41356A-page 22 CAUTION CAUTION ® shortcut. Great care should be taken to ensure that © 2008 Microchip Technology Inc. ...
Page 27
... If the state condition has been met, the state is changed to the next sequential state. The state variable is declared as a type static as this will allow the current value in the state variable to remain after a return from the keyboard(). © 2008 Microchip Technology Inc. STATE DIAGRAM FOR KEYBOARD() delaycounter < 9000 STATE 0 delaycounter > ...
Page 28
... The report descriptor has changed from the previous lab and will contain 63 components that the Host PC will need to identify this device’s keyboard attributes. 4. Scroll down to the report descriptor and add the code in Example 2-8 in the section labeled: //ADD REPORT DESCRIPTOR HERE DS41356A-page 24 http://www.usb.org/devel- © 2008 Microchip Technology Inc. ...
Page 29
... ADCON0=0x29; // ADCON1 = 0X00; // ADCON2=0x3F; Scroll down to the keyboard() and copy and paste the code in Example 2-9 between the curly braces in the switch at: //ADD STATE MACHINE CODE HERE © 2008 Microchip Technology Inc. REPORT DESCRIPTOR FOR KEYBOARD() // USAGE_PAGE (Generic Desktop) // USAGE (Keyboard) ...
Page 30
... HIDoutput = 29; //Can the SIE transmit? if((HIDTxHandleBusy(lastTransmission) == 0)) { //Load the HID buffer hid_report_in[ hid_report_in[ hid_report_in[2] = HIDoutput; hid_report_in[ hid_report_in[ hid_report_in[ hid_report_in[ hid_report_in[ //Send the 8 byte packet over USB to the host. lastTransmission = HIDTxPacket(HID_EP, (BYTE*)hid_report_in, 0x08); state = 0; } break; //completed © 2008 Microchip Technology Inc. ...
Page 31
... Turn the potentiometer on the Low Pin Count USB Demo Board to change the character on the screen. The user is encouraged to experiment with this application by referring to the Keyboard Usage Page and changing the keyboard packet transmitted in the state machine. © 2008 Microchip Technology Inc. DS41356A-page 27 ...
Page 32
... Pin Count USB Development Kit is designed to serve as an intermediary between a USB-connected PC and an RS-232 peripheral – such as an alarm panel or a remote control. Overview of the CDC – Serial Emulator Firmware The CDC Serial Emulator firmware flow is shown in Figure 2-5. DS41356A-page 28 © 2008 Microchip Technology Inc. ...
Page 33
... FIGURE 2-5: © 2008 Microchip Technology Inc. FLOWCHART FOR CDC SERIAL EMULATOR CODE ProcessIO( ) RS232 OUT Buffer available and USB OUT Buffer NOT EMPTY NO RS232 OUT Buffer NOT EMPTY and EUSART is EMPTY NO EUSART has a byte NO RS232 IN Buffer has data and USB IN Buffer available ...
Page 34
... It is called once each time through the main program loop. The state machine for the CDCTxService() is shown in Figure 2-6 and the source code can be found in the usb_function_cdc.c source file. The reader is encouraged to reference this firmware and compare it against the state diagram at their leisure. DS41356A-page 30 © 2008 Microchip Technology Inc. ...
Page 35
... This time, the project will be set up to resemble the application examples in the Framework using sub-folders to distinguish and organize the different source files in the Project window. 2. Right click on the Source Files folder in the Project window and select Create Subfolder... © 2008 Microchip Technology Inc. CDCTXSERVICE( ) STATE DIAGRAM DS41356A-page 31 ...
Page 36
... Project, Use Absolute Path” is selected then click Open. FIGURE 2-8: This should add the usb_device.c to the “USB Stack” folder in the Project window. DS41356A-page 32 CREATING A SUB-FOLDER IN THE PROJECT WINDOW ADDING THE USB_DEVICE.C FILE TO THE USB STACK FOLDER © 2008 Microchip Technology Inc. ...
Page 37
... Compiler.h • GenericTypeDefs.h 7. Ensure that the Project Build Options are configured as was done in Lab 1 steps 11 through 15. 8. Compile the project. There should be no errors. The Project window should now resemble Figure 2-9. © 2008 Microchip Technology Inc. DS41356A-page 33 ...
Page 38
... UserInit(). Note that in this function, code has been formatted to allow configuration dependant on the specific device and compiler used. Copy and paste the contents of Example 2-10 into the section of the Initialize- USART() function labeled: //ADD C18 PIC18F14K50 EUSART INITIALIZATION CODE HERE DS41356A-page 34 PROJECT WINDOW FOR LAB 4 © 2008 Microchip Technology Inc. ...
Page 39
... As per the flowchart in Figure 2-5, this code will ensure that the buffer containing the data transmitted from the RS-232 has been sent to the USB firmware. If so, the code then checks for any new RS-232 data that has been stored in the buffer. © 2008 Microchip Technology Inc. INITIALIZEUSART() CODE unsigned char c; ...
Page 40
... ADD THE CODE THAT WILL CHECK IF THE CDC CLASS DEVICE IS READY TO LOAD THE USB BUFFER *********************************************************/ DS41356A-page 36 RS-232 BUFFER CHECK LastRS232Out = getsUSBUSART(RS232_Out_Data,64); if(LastRS232Out > RS232_Out_Data_Rdy = 1; RS232cp = 0;// Reset the current position } TXREG CHECK AND LOAD CODE putcUSART(RS232_Out_Data[RS232cp]); ++RS232cp; if (RS232cp == LastRS232Out) RS232_Out_Data_Rdy = 0; // signal //buffer full © 2008 Microchip Technology Inc. ...
Page 41
... Windows will now prompt the user for driver information. 18. In the “Welcome to the Found New Hardware Wizard” window, select “No, not this time” and then Next. (see Figure 2-10) FIGURE 2-10: © 2008 Microchip Technology Inc. CHECK CDC CLASS DEVICE CODE putUSBUSART(&USB_Out_Buffer[0], NextUSBOut); NextUSBOut = 0; ...
Page 42
... Port connection for the USB. Ensure that both “Search for the best driver in these loca- tions” and “Include this location in the search” are both selected. Select Browse and navigate to the lab 4 source files in the C:\LPCUSBDK_Labs\Lab4_files\inf\win2k_winxp directory. (see Figure 2-12) DS41356A-page 38 SELECTING SOFTWARE LOCATION FOR COMMUNICATIONS PORT © 2008 Microchip Technology Inc. ...
Page 43
... The wizard should indicate that the software for the Communications port was successfully installed. Select Finish. (See Figure 2-13) FIGURE 2-13: © 2008 Microchip Technology Inc. DIRECTING WINDOWS TO THE .INF FILE FOR THE CDC – SERIAL EMULATOR APPLICATION SUCCESSFUL SOFTWARE INSTALLATION WINDOW ...
Page 44
... Open a Hyper Terminal window by selecting within Windows, Start>Programs>Accessories>Communications>HyperTerminal. The Hyper Terminal Program should now prompt the user for a “Connection Description”. 23. Name this first connection “USB Connection” and click OK. (See Figure 2-15). DS41356A-page 40 EXAMPLE LIST OF AVAILABLE COM PORTS IN THE DEVICE MANAGER © 2008 Microchip Technology Inc. ...
Page 45
... Virtual COM Port is on COM7. Note that this may differ on the user’s PC. FIGURE 2-16: 25. In the COM Properties window, configure the connection as shown in Figure 2-17 with a baud rate of 19200 and click Apply then OK. © 2008 Microchip Technology Inc. HYPER TERMINAL CONNECTION DESCRIPTION HYPER TERMINAL CONNECT TO WINDOW DS41356A-page 41 ...
Page 46
... Note that unless configured to echo locally, the originating message COM window will not print the message. The message should be printed in the “USB Connection” COM window as shown in Figure 2-18. DS41356A-page 42 HYPER TERMINAL COM PROPERTIES WINDOW © 2008 Microchip Technology Inc. ...
Page 47
... FIGURE 2-18: This will confirm communication from the Host PC via an RS-232 connection into the PIC18F14K50 which in turn transmits data received back to the Host PC. In other words, an RS-232 to USB conversion. © 2008 Microchip Technology Inc. CONFIRMING RS-232 TO USB COMMUNICATION DS41356A-page 43 ...
Page 48
... Low Pin Count USB Development Kit User’s Guide NOTES: DS41356A-page 44 © 2008 Microchip Technology Inc. ...
Page 49
... Appendix A. Schematics A.1 INTRODUCTION This appendix contains the Low Pin Count USB Development Kit hardware diagrams. FIGURE A-1: PICkit™ 2 USB DEVELOPMENT SCHEMATIC © 2008 Microchip Technology Inc. LOW PIN COUNT USB DEVELOPMENT KIT USER’S GUIDE DS41356A-page 45 ...
Page 50
... Low Pin Count USB Development Kit User’s Guide FIGURE A-2: PICkit™ 2 DEBUG HEADER PIC18F1XK50-ICD_S028 V DD PIC18F1XK50-I PIC18F1XK50-I/P DS41356A-page REF V - REF REF V - REF CV / REF © 2008 Microchip Technology Inc. ...
Page 51
... LOW PIN COUNT USB DEVELOPMENT KIT USER’S GUIDE NOTES: © 2008 Microchip Technology Inc. DS41356A-page 47 ...
Page 52
... Fax: 886-3-572-6459 Taiwan - Kaohsiung Tel: 886-7-536-4818 Fax: 886-7-536-4803 Taiwan - Taipei Tel: 886-2-2500-6610 Fax: 886-2-2508-0102 Thailand - Bangkok Tel: 66-2-694-1351 Fax: 66-2-694-1350 © 2008 Microchip Technology Inc. EUROPE Austria - Wels Tel: 43-7242-2244-39 Fax: 43-7242-2244-393 Denmark - Copenhagen Tel: 45-4450-2828 Fax: 45-4485-2829 France - Paris Tel: 33-1-69-53-63-20 ...