USB HID Initialize

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
electrolaw
Posts: 8
Joined: Mon Mar 12, 2012 8:19 am
Has thanked: 6 times
Been thanked: 4 times

USB HID Initialize

Post by electrolaw »

Hi,

I have a project using the PIC18F2550. I'm trying to get the USB HID to initialize.

As I understand the help file, Initialise_HID() will return 0 it the startup was successful and 255 if the startup failed or timed-out.

My problem is that Initialise_HID() is not returning anything. The code just stops when it gets to the initialise_HID() macro. I can deal with it not enumerating and returning 255, but can't figure out why it is not returning anything at all.

My descriptor file is as follows:

0x06,0xA0,0xFF, //Usage Page - Vendor Defined
0x09,0x01, //Usage - Vendor Defined
0xA1,0x01, //Collection - Application
0x09,0x02, //Usage - Vendor Defined
0xA1,0x00, //Collection - Linked
0x06,0xA1,0xFF, //Usage Page - Buttons
0x09,0x03, //Usage - Vendor Defined
0x09,0x04, //Usage - Vendor Defined
0x15,0x00, //Logical Minimum - 0
0x26,0xFF,0x00, //Logical Maximum - 255
0x35,0x00, //Physical Minimum - 0
0x45,0xFF, //Physical Maximum - 255
0x75,0x08, //Report Size - 8bits
0x95,0x03, //Report Count - 3fields
0x81,0x02, //Input - Data Variable Absolute
0x09,0x05, //Usage - Vendor Defined
0x09,0x06, //Usage - Vendor Defined
0x15,0x00, //Logical Minimum - 0
0x26,0xFF,0x00, //Logical Maximum - 255
0x35,0x00, //Physical Minimum - 0
0x45,0xFF, //Physical Maximum - 255
0x75,0x03, //Report Size - 8bits
0x95,0x08, //Report Count - 3fields
0x91,0x02, //Output - Data Variable Absolute
0xC0, //End Collection
0xC0 //End Collection

I copied the customized descriptor property from an example posted by Benj here. http://www.matrixmultimedia.com/mmforum ... tor#p13074

Do I need to modify the "Customized code" screen since I am using a custom descriptor property? If so, what should the custom code properties be?

I have attached a file with a snippet of the applicable code(without project settings, etc.} All of the rest of my code(which I have not included in the uploaded file) works fine. If there are some settings to fiddle with please let me know. Thanks. :D
Attachments
Upload.fcf
(10 KiB) Downloaded 293 times
Last edited by electrolaw on Mon Jul 01, 2013 9:14 am, edited 1 time in total.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: USB HID Initialize

Post by Benj »

Hello,

In the USB component properties switch on the Enumeration Wait setting. This will enable the timeout and allow the init macro to return if the enumeration is not completed correctly.

I see a couple of reasons why your code is not running correctly.

1) your clock speed is set to 19660800 MHz, this should be set to 48000000 to specify the USB speed.

2) You have no configuration settings set in your program so the chip will not run. See here for correct config settings for this device.
http://www.matrixmultimedia.com/article.php?a=363

electrolaw
Posts: 8
Joined: Mon Mar 12, 2012 8:19 am
Has thanked: 6 times
Been thanked: 4 times

Re: USB HID Initialize

Post by electrolaw »

Hi Benj,

The code in the file I uploaded is just a snippet that I copied to a new file for upload. I did not bother to set the clock, etc. but all of that is set correctly in the original program. I did not post the entire program because it is proprietary, but I could email it to you if necessary.

I previously tried your suggestion about changing the Enumeration Wait setting, but Initialise_HID() still would not return anything.

Sorry, also, I edited my original post as you were posting your reply, Could you take a look at it to see if anything else could be wrong?

Gary Freegard
Posts: 45
Joined: Mon Nov 07, 2011 6:36 pm
Has thanked: 1 time
Been thanked: 30 times

Re: USB HID Initialize

Post by Gary Freegard »

Hi

I have just used modified Ben's example http://www.matrixmultimedia.com/mmforum ... tor#p13074 for PIC 18F2455. I use portA.0 to show that it has initialized.

All you will need to do is change the pic.

Also you need to have a 220nF cap connect between ground and pin 14 (Vusb).

Good Luck

Gary
Attachments
HID.fcf
(14 KiB) Downloaded 306 times

Post Reply