USBKeyboard noyt working

Good morning,
I am trying to make a simple keyboard with my STM32 Nucleo F746ZG. I have made it works a couple of years ago in MBED, but now that everything is updated I am having some issues:
The program is

#include “mbed.h”

#include “USBKeyboard.h”

// Blinking rate in milliseconds
#define BLINKING_RATE 1000ms

int main()
{
// Initialise the digital pin LED1 as an output
DigitalOut led(LED1);
USBKeyboard key0;

while (true) {
    led = 1;
    ThisThread::sleep_for(BLINKING_RATE);
    led = 0;
    ThisThread::sleep_for(BLINKING_RATE);
    key0.printf("Hello world \n");
}

}

If I remove the ‘USBKeyboard key0;’ line it blinks. The programs build succesfully, I can upload it on the Nucleo but I can’t see neither the link blink with this line nor the keyboard typing anything. Windows 10 recognizes it as a “STM32 STLink” Device and even updating the driver with the latest one doesn’t help.

Also I can’t list the Nucleo in “Connected Device” on Keil Studio in any way. This doesn’t feel normal.
Does someone have any suggestion, please?
Marco

Hello,

your code probably stuck in the constructor of USBKeyboard and is waiting for a connection via a USB cable and recognition from a Host side, PC in your case.

Your system have to recognize 3-4 devices after power up:

  • Something for MSD (ST-link’s memory for drag & drop upload)
  • ST-link VCP (a COM port)
  • ST-link Debug (debugger)
  • Mbed keyboard (or something similar) probably under HID section in the Windows device manager

Do you have connected also the second USB (closer to the ethernet port)?

BR, Jan

Thank you, I really appreciated your (quick) response. After connecting the other usb port the Nucleo started working as a keyboard. Now I see that the keyboard (this saved my day), the debugger and the COM port are present. I can’t make it recognized on Keil Studio, but this is a minor issue

Marco

Cool.
The ST-link must be first manually added in the device manager (last icon on left panel).

BR, Jan

Unfortunately I can’t do that. In the Device Manager, under the Device tab, nothing spwans even after I plug the Nucleo. Digitating “ST-Link” doesn’t change anyhhing. “Refresh Devices” also does nothing. Maybe there is a problem with the device permissionsof my browser (Firefox)?

I do not know I do not use Firefox, just MS Edge.

BR, Jan

Hello @MMastro,

To work with development boards over USB, you must use Keil Studio Cloud in a desktop browser
that supports the WebUSB standard: Google Chrome or Microsoft Edge (Chromium).

Have you tried using one of these browsers?

Elise - Studio team.

Thank you, miss Elise, I can confirm on Microsoft Edge the debug works. Unfortunately I still can’t run my app and the system doesn’t give me any code to understand why.

Above you wrote about the keyboard is working, so what is not working now?

BR, Jan

Mr JhonnyK the program now works. I was trying to take advantage of the presence of Miss Kaminski to see if Keil Studio could be used to debug the program (this would speed up the development on my Nucleo). However if this is not possible, your help already solved the problem about my program, and this is plenty for me to go on =)

Marco