cancel
Showing results for 
Search instead for 
Did you mean: 

USB HID communication

vikram2399
Associate II
Posted on October 18, 2011 at 15:09

Hi,

I am working on the USB HID communication where I am trying to send 1K bytes of data from host to device. I am using the ST32F107V microcontroller and teh board used is STM3210C-EVAL.

I am able to send 64 bytes at a go by changing the size of max lenght in the usb_desc.c file and also the value of max_lenght to 64 in the function OTG_DEV_EP_Init() in the usb_prop.c.

My query is that i am not able to increase the size of transfer beyond 64.

Are there any other fucntions or registers apart from the above mentioned that need to be changed for the application.

I also studied the reference manual of the ST M3 microcontroller to check if there are any registers specifically defined for USB.

However did not succeed in finding any.

Also one more query is : by changing the value of OTG_FS_GRXFSIZ does the generation of interrupt changes?

#usb
4 REPLIES 4
drzile86
Associate II
Posted on October 19, 2011 at 17:52

Hi,

Maximum size of USB HID packet is 64 byte, by USB 2.0 protocol.

How to send 1KB of data with USB HID from host to device -> For example:

You should divide your 1KB into chunks of 62 bytes. On every chunk you should add first byte (report ID) and second byte which is chunk index. So now you have 64 bytes.

On the device, based on the report ID and chumk index you parse data, and store in 1KB buffer.

Regards,

Dragan

vikram2399
Associate II
Posted on October 21, 2011 at 07:23

Thankyou.

That works. Now that it is working, I have come up with other query. Is there any way that the application can be modified to send more that 1K bytes of data but only 1K at a time?

I mean to say that currently I am using USB demonstrator as my host wherein once I click on write button it sends the data directly to the Recieve Buffer and then goes to the hard fault loop.

What I want to do is that once I click the write button the host transfers 1K of data and does not go into hardfault loop. Instead it waits in the while loop, for second time for the write button to be clicked for next chunk of data to be send 

Regards,

Vikram

drzile86
Associate II
Posted on October 24, 2011 at 18:31

Hi,

If you have source code of the USB HID application, you can do it, but you have to know writing of MFC applications.

In several projects, I have adapted USB HID app, I added some more buttons, edit box etc., but I have never send more than 1K of data, I have always send 64 bytes.

But sending 1K is similar, if you divide that in 64 chunks and maybe have some handshaking. 

Regards,

_behn4m
Associate II
Posted on February 22, 2014 at 09:37

Hi, I'm trying to use USB HID for a touch panel with STM32 and i don't know how I should start! would you please help me?

I know basics about STM32 and also USB, but I need more information and sample codes.

Thank you