How to use PIC18 with MCP USB Chip to do HID?


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    May 2016
    Posts
    33

    Default How to use PIC18 with MCP USB Chip to do HID?

    Hello all,

    I would like to create a mouse device using a pic18f24j50 and a mcp2200 or mcp2221 USB chip to do HID.

    Both these chips come with proprietary DLLs.So I am not sure how I can use them in PicBasic.

    I am trying to send HID descriptor to a pc using I2C to USB chip or UART to USB chip.

    Any idea how this can be done?

    There are open source C libraries for them as well but not sure if it's possible to use C in basic.

    I would like to use my existing and working Basic code.The only way I am thinking is to change the firmware of the chips with a pic firmware and load usb_hid.c to create an interface to do it.

    I appreciate any help.

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: How to use PIC18 with MCP USB Chip to do HID?

    You seem a little confused. In particular
    I am trying to send HID descriptor to a pc using I2C to USB chip or UART to USB chip
    The pic18f24j50 already has USB full speed hardware built in and PIC Basic has all the necesary "libraries" to implement HID.

    Perhaps you should say what you trying to acheive in broad terms.

    USB is very confusing to start (and sadly for most of us still continues to be). Try building one of the samples and try changing it a little. Also sadly you need to hit the books - the obvious one being USB complete by Jan Axelson or alternatly USB in a Nutshell.
    George

  3. #3
    Join Date
    May 2016
    Posts
    33


    Did you find this post helpful? Yes | No

    Default Re: How to use PIC18 with MCP USB Chip to do HID?

    I got the onboard USB working with EASYHID and the hid libraries but I would like to replace it with USB chip to get over vendor id problem.

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: How to use PIC18 with MCP USB Chip to do HID?

    You can set the VID and PID (vendor id and product id) to anything you like. Look in the descriptor file.

    BTW the MCP 2200 id just a pre-programmed 18F14K50. See this article http://hackaday.com/2011/01/18/mcp22...-your-bidding/
    Last edited by towlerg; - 10th June 2016 at 14:13. Reason: old and stupid
    George

  5. #5
    Join Date
    May 2016
    Posts
    33


    Did you find this post helpful? Yes | No

    Default Re: How to use PIC18 with MCP USB Chip to do HID?

    I am trying to change more than VID and PID in the MCP2200 descriptor but there is no way to do it using the methods described.There is no HID mouse report descriptor in the descriptor. Basically I want to add hid mouse report descriptor to the MCP2200 descriptor and send data packets using PIC18 through UART OR I2C. In other word: A mouse using PIC and a USB Bridge.I don't want to use the onboard USB as it doesn't have a vendor id and I want to release the final code as an open source project. Am I missing anything?

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: How to use PIC18 with MCP USB Chip to do HID?

    Am I missing anything?
    Simple answer, yes.

    The MCP2200 is a preprogrammed PIC, which appears to the world as a USB to Serial convertor. Ading a mouse descriptor and the necesary software to service the descriptor is essentially impossible (no flames please). You would be much better of starting with a 18F14K50, modifying a HID sample.

    The data sheet gives details of how to change it's PID (among other things). From the data sheet -

    The configuration utility provided by Microchip allows the user to configure the MCP2200 to custom defaults. The configuration utility (shown in Figure 2-1) connects
    to the device’s HID interface, where all of the configurable features can be set.
    Name:  Untitled.jpg
Views: 1989
Size:  93.9 KB

    .I don't want to use the onboard USB as it doesn't have a vendor id
    Incorrect. The VID and PID are changed in the descriptor file which will be part of the compiled project.

    eg The portion of gen_desc.bas which defines the VID (among other things), in this case 04D8 hex.
    Code:
    DeviceDescriptor
    	retlw	(EndDeviceDescriptor-DeviceDescriptor)/2	; Size of this descriptor in bytes
    	retlw	USB_DESCRIPTOR_DEVICE	; DEVICE descriptor type
    	retlw	0x10		; USB Spec Release Number in BCD format - 1.10 (low byte)
    	retlw	0x01		; (high byte)
    	retlw	0x00		; Class Code
    	retlw	0x00		; Subclass code
    	retlw	0x00		; Protocol code
    	retlw	USB_EP0_BUFF_SIZE	; Max packet size for EP0
    	retlw	0xD8		; Vendor ID - 0x04D8 is Microchip Vendor ID (low byte)
    	retlw	0x04		; (high byte)
    	retlw	0x0C		; Product ID: PICDEM FS USB (DEMO Mode) (low byte)
    	retlw	0x00		; (high byte)
    	retlw	0x00		; Device release number in BCD format (low byte)
    	retlw	0x00		; (high byte)
    	retlw	0x01		; Manufacturer string index
    	retlw	0x02		; Product string index
    	retlw	0x00		; Device serial number string index
    	retlw	NUM_CONFIGURATIONS	; Number of possible configurations
    EndDeviceDescriptor
    I don't understand your references to mice?
    Last edited by towlerg; - 15th June 2016 at 13:56.
    George

Similar Threads

  1. Olimex PIC-MCP-USB
    By Tawcafts in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 1st March 2012, 17:54
  2. PIC18 connect to USB thumb drive
    By Pic2008 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 27th April 2011, 18:15
  3. Usb hid
    By yatyas72 in forum USB
    Replies: 5
    Last Post: - 3rd December 2010, 15:45
  4. PIC18 USB Programmer
    By r0nd0m in forum Off Topic
    Replies: 1
    Last Post: - 23rd February 2009, 15:59
  5. PIC18 USB simple example needed
    By harryweb in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 29th September 2005, 22:20

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts