cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103C8 USB Unknown Device Problem

ferhatyol-23
Senior
Posted on July 27, 2017 at 15:51

Hi friends

I am trying to make usb hid connection with STM32F103C8. I was able to compile the USB Library via the KEIL Compiler. The processor is running. After the USB init routines, the processor goes to the main program. And when I make the USB connection, I get the error that the ''USB Unknown Device''

USB connection as shown

0690X00000603ywQAA.jpg

My project file is attached.  Can someone review the project?

What causes this problem?

#stm32 #usb #stm32f103
12 REPLIES 12
STOne-32
ST Employee
Posted on July 27, 2017 at 19:16

Dear gentleman,

You should check  the DP/PA12  ( D+) Pull -up management.   It should be 1.5Kohm and pulled to VDD ( 3Volts to 3.6Volts) and controlled by a GPIO to soft connect and disconnect it..  in software it is not inline using our default Eval bord configuration  PC9 pin.

Also check your crystal Value if it is 8MHz.

Cheers,

STOne-32.

Posted on July 28, 2017 at 10:19

As you said, I tried with 1K5 and 3.3V pull up. But this way the computer does not react at all. The device is not detected by the computer at all

Now I'm testing it with a 10K resistor and a 3.3V pull-up.  When I try with a 10K resistor on the circuit diagram, sometimes it works fine. Especially if you do nothing in the main program, the usb connection is provided properly.  However, the USB connection fails if you use an external hardware such as activate Timer interrupt etc. 

I do not understand what the problem is. What do you have to do with external equipment?

Posted on July 28, 2017 at 15:15

Does your device have its power supply, or feeds from host usb port?

Posted on July 28, 2017 at 16:13

Hi Mucit23,

On this moment I'm using a Blue Pill board that have also a

STM32F103, the only difference is that the PA12 is connected to 3.3V through a 10K resistor as you can see in the image below:

0690X00000607fBQAQ.png

I decided to ''port'' the example that is provided with the HAL using the CubeMX initialization to this board and works well, in the example the microcontrollers worksas an USB-to-serial converter, if you just power your micro with 3.3V the LED don't blink, but if you power the board through the usb port, the PC recognize the virtual serial port and the LED blinks. I attach the code to this post if want to check ita and in the folder is also de .ioc file of the CubeMX if you want to port it to Keil.

________________

Attachments :

F103C8_BLINK.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HyYn&d=%2Fa%2F0X0000000b9R%2Fz0PFgNAg3rAj9Ak52jUo.qsj50HIUPsF09iaW6hpDI0&asPdf=false
Posted on July 28, 2017 at 15:03

it seems like a hardware fault, did you check the 5V rails ?

Posted on July 28, 2017 at 16:34

Hi! 

10k pullup usb, 100pf!! caps for LSE crystal,  super bright (510Ohm) Leds , no VDDA 'some kind of  isolation'.  At least is cheap.!!

:)

ferhatyol-23
Senior
Posted on August 01, 2017 at 19:53

thanks for the reply. 

Now I have created a project with CubeMX for the USB hid example. When I run this project on the STM32F103, the computer recognizes my device as a USB Mouse. But I want to use it as a Custom HID device. How are the settings related to this? How do I fix my descriptor file?

Posted on August 01, 2017 at 20:24

0690X00000607m7QAA.png
ferhatyol-23
Senior
Posted on August 02, 2017 at 11:46

No, There is no problem with stack size. I understand the problem. I need to fill in the Report Description section in the USB Custom Hid project

__ALIGN_BEGIN static uint8_t CUSTOM_HID_ReportDesc_FS[USBD_CUSTOM_HID_REPORT_DESC_SIZE] __ALIGN_END =

{

/* USER CODE BEGIN 0 */

0x00,

/* USER CODE END 0 */

0xC0 /* END_COLLECTION */

};

The device can not be started by the PC because this function is empty. How to create USB Report Description?