View previous topic :: View next topic |
Author |
Message |
SuperDave
Joined: 22 May 2008 Posts: 63 Location: Madison, TN
|
USB HID send first data |
Posted: Wed Jun 19, 2013 1:23 pm |
|
|
Delphi on the PC, CCS C compiler for 18LF13K50
Enumeration works fine. Trying to write some data to endpoint 0
Delphi
Code: | MyDevice.WriteFile(SendUSB, 5, Written) // actual data 0,1,2,3,4
returns true (ie. success, 0 is endpoint zero, next four bytes are simple data, written changes from 0 before to 5 after) |
CCS C - 18LF13K50 running and enumerated
Code: | void main() {
enable_interrupts(INT_USB); //not sure needed
enable_interrupts(global);
usb_init();
testdelay := 1; //to see scope change on C1
while (1) {
output_toggle(Pin_C1);
delay_ms(testdelay);
if (usb_kbhit(0)) { //should be true if endpoint 0 has data
testdelay = 2;
}
} //end while (1)
} //end main
|
TestDelay does not change from 1mS to 2mS. ie. usb_kbhit(0) is not triggering. Any idea why?
Configuration
Code: |
#ifndef USB_CONFIG_HID_TX_SIZE
//valid range is 0-255
#define USB_CONFIG_HID_TX_SIZE 4 //
#endif
#ifndef USB_CONFIG_HID_RX_SIZE
//valid range is 0-255
#define USB_CONFIG_HID_RX_SIZE 4 //
#endif |
|
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Wed Jun 19, 2013 3:54 pm |
|
|
Quote: |
Enumeration works fine.
|
on WHAT OS and version might that be ??
also -you post so little code, ( and no includes - etc etc )
- that I don't see how anyone will be able to help you solve this. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Thu Jun 20, 2013 12:37 am |
|
|
USB endpoint 0, is reserved in USB for device control transfers.
Can't have less than 8 bytes. Normally controls things like DTR etc..
Your normal transfers cannot use this endpoint.
Best Wishes |
|
|
SuperDave
Joined: 22 May 2008 Posts: 63 Location: Madison, TN
|
|
Posted: Thu Jun 20, 2013 5:12 am |
|
|
Thank you. Your statement "Can't have less than 8 bytes." is at odds with the configure comment "//valid range is 0-255" Is endpoint 0 restricted to 8 bytes? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Thu Jun 20, 2013 7:26 am |
|
|
Yes.
It is in the USB spec.
The very first packet sent to any USB device, is a 'setup' packet on endpoint 0, and is 8 bytes in size. This happens as the first part of enumeration. EP0, is reserved for command packets.
Best Wishes |
|
|
|