cancel
Showing results for 
Search instead for 
Did you mean: 

HID keyboard not working on STM32F722ZE (NUCLEO-F722ZE board)

kaamil1984
Associate II

Hi guys,

I'm trying to use STM32 as a host for a HID keyboard and mouse.

I have 2 wireless mouses to test (Logitech M560, HP Spectre 700), Logitech T-BC21 wired trackball, some low-end keyboard. I'm connecting them via micro-USB to USB converter that works properly with my old tablet.

LED near USB port on NUCLEO lights up, looks like it enumerates my all test devices (function returns OK), but I'm always getting stuck in USBH_HID_POLL state and I never get this condition true (after pressing keys, moving or clicking mouses):

 

 

// usbh_hid.c USBH_HID_Process(...) function
if (USBH_LL_GetURBState(phost, HID_Handle->InPipe) == USBH_URB_DONE)

 

 

I'm following this tutorial from ControllersTech, that basically just uses generated code, except that I'm using FreeRTOS. USB interrupt is enabled (can't be turned off in code generator).

I'm powering NUCLEO from my PC USB port (programming/debugging). I have not tried to power the board from external 5V supply, but I don't think this could make any difference, since the keyboard is relatively low power.

 

My environment:

STM32CubeIDE

Version: 1.13.2

Build: 18220_20230914_1601 (UTC)

Here is my configuration:

kaamil1984_0-1699847319586.png

kaamil1984_1-1699847352678.png

 

 

 

 
1 ACCEPTED SOLUTION

Accepted Solutions
kaamil1984
Associate II

I have found a solution.

The problem was in 1.17 software package. 

I have crated two identical projects:

  • FW 1.16.2 (CubeIDE  1.9.0) - this is working
  • FW 1.17 (CubeIDE 1.13.2 - most recent at this time) - this is not working

It looks like new driver or middleware is somehow broken.

The problem is blooming on github for few months (link), looks like it affects various USB demo applications for Discovery and Nucleo devices (confirmed by others on github) and also generated middleware or driver code in my case.

Thanks for your interest guys, I hope the staff will find time to look into it. So far, the most reasonable solution is to use an older version of the IDE with an older firmware package (the new version of the IDE does not support FW 1.16.2).

View solution in original post

5 REPLIES 5
KDJEM.1
ST Employee

Hello @kaamil1984 ,

I advise you to get inspired from an available HID_StandaloneI example available in STM32CubeF7 package.

This is a typical application on how to use the STM32F722ZE USB OTG Host peripheral to interact with an USB HID Device such as a Mouse or a Keyboard. 

I think this example may help you to configure the HID keyboard by following the instructions in the readme file.

I hope this help you.

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

So I have started this example, but without Adafruit thing.

I'm changing `hid_state` to `HID_DEMO_START` manually in the Live Expressions instead of menu.

`USBH_HID_GetDeviceType` returns type correctly. When I connect the mouse state changes to HID_MOUSE, and the mouse application state switches HID_MOUSE_IDLE, and then goes forward until HID_MOUSE_WAIT.

In HID_MOUSE_WAIT this code is called in loop:

static void USBH_MouseDemo(USBH_HandleTypeDef *phost)
{
  HID_MOUSE_Info_TypeDef *m_pinfo;  
  
  m_pinfo = USBH_HID_GetMouseInfo(phost);
  if(m_pinfo != NULL)
  {
    /* Handle Mouse data position */
    USR_MOUSE_ProcessData(&mouse_info);
    
    if(m_pinfo->buttons[0])
    {
      HID_MOUSE_ButtonPressed(0);
    }
    else
    {
      HID_MOUSE_ButtonReleased(0);
    }
    // ... 
  }
}

But `USBH_HID_GetMouseInfo` is never called, because `m_pinfo` is always NULL.

I also tried wired optical USB mouse and effect is still the same.

What is going on?

Pavel A.
Evangelist II

You wrote that you have several mouse models. Can you find a very old mouse, some Microsoft or IBM model? Unfortunately mice use many formats of HID report, much more versatile than keyboards. Probably something goes wrong in the HID data parsing code. Try to debug.

 

kaamil1984
Associate II

I have found a solution.

The problem was in 1.17 software package. 

I have crated two identical projects:

  • FW 1.16.2 (CubeIDE  1.9.0) - this is working
  • FW 1.17 (CubeIDE 1.13.2 - most recent at this time) - this is not working

It looks like new driver or middleware is somehow broken.

The problem is blooming on github for few months (link), looks like it affects various USB demo applications for Discovery and Nucleo devices (confirmed by others on github) and also generated middleware or driver code in my case.

Thanks for your interest guys, I hope the staff will find time to look into it. So far, the most reasonable solution is to use an older version of the IDE with an older firmware package (the new version of the IDE does not support FW 1.16.2).

KDJEM.1
ST Employee

Hello @kaamil1984 ,

Thank you for bringing this issue to our attention.

I confirm the issue and I reported internally.

Internal ticket number: 166306 (This is an internal tracking number and is not accessible or usable by customers).

Thank you.

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.