10 years, 4 months ago.

Wiring and frequency

Hi,

I have ST Nucleo F401 RE and I try to make simple USB HID program. My program looks like this:

#include "mbed.h"
#include "USBHID.h"

DigitalOut myled(LED1);
USBHID hid(1, 1, 0x1234, 0x0006, 0x0001, false);

int main() {
    myled = 1;
    wait(1.0);
    
    hid.connect(true);

    while(1) {
        myled = !myled;
        wait(1.0); // 1 sec
    }
}

Dev board is connected to computer via two cables see image: /media/uploads/vrabec/img_7160.jpg

But program stuck in connection. I debug little bit and it seems, device (in USBDevice) is in state POWERED (default state), but not in state connected. Can you help me? Is my wiring insufficient?

Question relating to:

USB device stack with Nucleo F401RE support. NOTE: the default clock config needs to be changed to in order for USB to work. device, Nucleo, USB

I also change frequency of build in oscillator as proposed.

posted by Michal Stehlik 06 Jul 2014

A ground connection may help. You'll be getting one to the PC through the debug USB port but the USB device ground should also be connected.

posted by Andy A 07 Jul 2014

Hi, I am facing the same issue as above. I connected ground pin (to PA_10) and power pin to PA_9. and also did the clock modifications suggested in mbed-src. However still I am getting stuck in Device intialization (ie:- USB examples for mouse/keboard/ above USB HAL #connect is not working unfortunately). I wonder whether I am missing something here, I tried with/without power/GND pin as well. Do we need to modify pin configuration in code in someway ? Any feedback/suggestions are much appreciated.

Thanks

posted by uwick. W 26 Nov 2014

1 Answer

10 years, 4 months ago.

Hi Michal,

Connecting the USB power pin to PA9 might be required for USB functionality to work. Does USBSerial work properly?

Accepted Answer

I just checked and it looks like there is no need to change any clock settings if the latest mbed library build is used. I also tested the USBMouse example and it works so there should not be any problems with USBHid.

posted by Tomas Cerskus 07 Jul 2014

I haven't got this one myself, but isn't it running by default on the internal oscillator? It might be accurate enough in your sample, but not guaranteed. I believe you can let it get a clock from the ST link. But as I said, don't got it myself, and maybe that already is the default.

posted by Erik - 07 Jul 2014

Thank you guys, connecting PA9 helps :)

posted by Michal Stehlik 07 Jul 2014