Easy HID
Moderators: David Barker, Jerry Messina
Easy HID
Hi i thought it was about time i tried using USB HID comms as the usb cdc has various issues for what i'm doing.
i've tried generating the files with the Easy HID add on and it finds the device, the add new hardware wizard pops up i click to install but it says hannot start the hardware(code 10).
i'm actually using a 18f2553 and i've tried compiling for a 2553 and for a 2550 but it makes no difference.
i've added
const
TXReportRAM = TX_REPORT_RAM,
RXReportRAM = RX_REPORT_RAM
as jerry suggested to let it compile.
i left the settings to default in easy hid.
any ideas?
i've tried generating the files with the Easy HID add on and it finds the device, the add new hardware wizard pops up i click to install but it says hannot start the hardware(code 10).
i'm actually using a 18f2553 and i've tried compiling for a 2553 and for a 2550 but it makes no difference.
i've added
const
TXReportRAM = TX_REPORT_RAM,
RXReportRAM = RX_REPORT_RAM
as jerry suggested to let it compile.
i left the settings to default in easy hid.
any ideas?
Hmmm..
- David Barker
- Swordfish Developer
- Posts: 1214
- Joined: Tue Oct 03, 2006 7:01 pm
- Location: Saltburn by the Sea, UK
- Contact:
Code 10 looks like a windows driver problem, looking at this:
http://pcsupport.about.com/od/findbyerr ... -error.htm
http://pcsupport.about.com/od/findbyerr ... -error.htm
-
- Swordfish Developer
- Posts: 1473
- Joined: Fri Jan 30, 2009 6:27 pm
- Location: US
I think you'll get that one if you're not servicing the USB often/fast enough, too.
When it first starts up and begins to enumerate, you pretty much can't do anything else until that completes. At that point, you have to be able to get and service the packets at about 100us intervals.
Once that dance is over, then you have a bit more leeway.
Are you using polling or interrupts? If you post your main program, perhaps we can see what the issue might be.
When it first starts up and begins to enumerate, you pretty much can't do anything else until that completes. At that point, you have to be able to get and service the packets at about 100us intervals.
Once that dance is over, then you have a bit more leeway.
Are you using polling or interrupts? If you post your main program, perhaps we can see what the issue might be.
Hi,
Thanks for the replys,
it seems the code that i used from the easy hid plugin is the problem
this doesnt work, but the sample within the sf directory seems to work ok
I now have another hid problem at the pc end but i think i should ask this in a seperate thread
Thanks for the replys,
it seems the code that i used from the easy hid plugin is the problem
Code: Select all
{
*****************************************************************************
* Name : USBPROJECT.BAS *
* Author : [select VIEW...EDITOR OPTIONS] *
* Notice : Copyright (c) 2013 [select VIEW...EDITOR OPTIONS] *
* : All Rights Reserved *
* Date : 22/02/2013 *
* Version : 1.0 *
* Notes : *
* : *
*****************************************************************************
}
// device and clock...
Device = 18F2553
Clock = 48
// 20Mhz crystal, 48Mhz internal (FS USB)
Config
PLLDIV = 5,
CPUDIV = OSC1_PLL2,
USBDIV = 2,
FOSC = HSPLL_HS,
VREGEN = ON
// this is the programs descriptor, generated by EasyHID - you
// can find it in the same folder as this program...
#option USB_DESCRIPTOR = "USBProjectDesc.bas"
// import the HID module...
Include "usbhid.bas"
Const
TXReportRAM = TX_REPORT_RAM,
RXReportRAM = RX_REPORT_RAM
// an example TX report structure, which contains a message
// string and two word values - the variable TXReport will overlay
// the structure over the USB dual port RAM buffer...
Structure TTXReport
Message As String
ValueA As Word
ValueB As Word
End Structure
Dim TXReport As TTXReport Absolute TXReportRAM
// an example RX report structure, which contains some bit
// value and a configuration byte - the variable RXReport will overlay
// the structure over the USB dual port RAM buffer...
Structure TRXReport
LED0 As Bit
LED1 As Bit
Configuration As Byte
End Structure
Dim RXReport As TRXReport Absolute RXReportRAM
// rather than using the above structures, you can read and write data
// directly into a buffer array - choose which method you prefer - examples
// are given in the main program block...
Dim Buffer(32) As Byte
// connect to USB...
Repeat
Until Attached
// the main program loop shows two different ways in which you can read and
// write HID data. The ReadReport() and WriteReport() techniques are very useful
// when sending and receiving highly structured data (for example, string, bits,
// words etc). If you just want to send and receive blocks of bytes, then
// ReadArray() and WriteArray() are probably more useful - you can of course
// use both ways!
While true
// this is one way you can read some HID data...
If DataAvailable Then
ReadReport
// the data is now in our RX structure - for example, PORTD.0 = RXReport.LED0 etc...
// Alternatively, you can access the buffer directly as an array. For example,
// HID.RXReport(0), HID.RXReport(1)...
EndIf
// rather than using ReadReport(), as shown above, you can read data directly
// into a buffer array. For example,
If DataAvailable Then
ReadArray(Buffer,10)
EndIf
// this is one way you can write some HID data...
TXReport.Message = "Hello World"
TXReport.ValueA = $1234
TXReport.ValueB = $0000
WriteReport
// rather than using WriteReport(), as shown above, you can write data directly
// into a buffer array. For example,
Buffer(0) = 0
Buffer(1) = 1
WriteArray(Buffer,2)
Wend
I now have another hid problem at the pc end but i think i should ask this in a seperate thread
Hmmm..
- David Barker
- Swordfish Developer
- Posts: 1214
- Joined: Tue Oct 03, 2006 7:01 pm
- Location: Saltburn by the Sea, UK
- Contact: