Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 5 months ago.
Nucleo-F103RB USBHID not working?
I am trying USB HID on Nucleo-F103RB. The program I am trying is trivial. However the program crashes. The program only instantiates USBHID class. This should be enough for USB host (running in the PC) to enumerate. The while loop in the main is a blinky program which is just an indicator if program is running or crashed. When I comment out USBHID instantiation, blinky works.
Note following: 1. The program works on FRDM-KL25Z. And PC identifies it as a USB device and provides information like PID and VID etc. 2. The USBHAL_IP_DEVICE.h file tells me that you need to connected a pull-up on D+ line. I did it, however no improvement.
So following is the simple program.
Program starts
- include "mbed.h"
- include "USBHID.h"
USBHID hid(8, 8);
DigitalOut led1(LED1);
int main(void) { led1 = 0;
while (true) { Thread::wait(500); led1 = !led1;
} } program ends
1 Answer
6 years, 5 months ago.
Hello Hemant,
- To assure correct format after pasting your program code here please surround it with markup tags (each on separate line) as below:
<<code>> your code <</code>>
- To make your program work try to add a new
mbed_app.json
file to your project with the content as below and then compile.
{ "target_overrides": { "NUCLEO_F103RB": { "target.clock_source_usb": "1" } } }
Thanks Zoltan. Next time will mark my code.
Yesterday I already figured out this. But it took couple of hours to know that the online build and hence default configuration won't work for USB. Also added following into the json file, because HSI is not recommended for USB.
<<code>>
"target.clock_source": "USE_PLL_HSE_XTAL"
<<code>>
Yet to try offline. Is it possible to use mbed_app.json with online build?
I would appreciate if the fact is prominently ("The online compilation and hence default configuration won't work for USB on Nucleo targets") documented.
Thanks again, Hemant
posted by 22 Jul 2018