Skip to main content
KOkte.1
Associate
April 3, 2023
Solved

STM32F107RCT7, FS USB Problem

  • April 3, 2023
  • 3 replies
  • 1205 views

I am having trouble with USB-FS communication with STM32F107RCT7.

When the board is connected to the PC via microUSB, the PC does not even detect something is connected to the PC.

I know that the PC detects a new device via a pull-up resistor on either DP or DM lines. In my case there needs to be 3.3V on DP pin via an Internal Resistor inside the MCU.

Checked the voltage on DP, it is zero.

Tried to debug the issue in STMCubeIDE:

I found the function responsible for USB initialization: HAL_PCD_MspInit

But there were no pin initialization for DP or DM pins.

Throughout the whole project I could'tn find any initialization on DP or DM pins.

Added the following code in HAL_PCD_Mspinit

__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Pin = USB_FS_DP_Pin|USB_FS_DM_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(USB_FS_DP_GPIO_Port, &GPIO_InitStruct);

Still no 3.3V on DP pin.

I cheked the DP pin on nucleo F767ZI board. There is indeed 3.3V on DP pin.

MCU is driven 25MHz0693W00000bhQ6TQAU.png 

Am I missing something, could there be a solution to my problem?

0693W00000bhQ5GQAU.png0693W00000bhQ5BQAU.png0693W00000bhQ56QAE.png0693W00000bhQ4wQAE.png 

This topic has been closed for replies.
Best answer by Ghofrane GSOURI

Hello @KOkte.1​ 

First let me thank you for posting .

Actually I tried to reproduce the issue mentioned above using the latest version 6.8.0 , I found that both functions " HAL_PCD_MspInit" and "HAL_PCD_MspDeInit" are missing.

So ,it has been reported to STM32CubeMX development team .

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

I will keep you posted with updates.

Thx

Ghofrane

3 replies

Ghofrane GSOURI
Ghofrane GSOURIBest answer
Technical Moderator
April 4, 2023

Hello @KOkte.1​ 

First let me thank you for posting .

Actually I tried to reproduce the issue mentioned above using the latest version 6.8.0 , I found that both functions " HAL_PCD_MspInit" and "HAL_PCD_MspDeInit" are missing.

So ,it has been reported to STM32CubeMX development team .

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

I will keep you posted with updates.

Thx

Ghofrane

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.
Ghofrane GSOURI
Technical Moderator
April 4, 2023

Hello @KOkte.1​ 

For the moment let's try to add this code

GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12;
 
 GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 
 GPIO_InitStruct.Pull = GPIO_NOPULL;
 
 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
 
 GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
 
 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 

0693W00000bhUcYQAU.png 

Thx

Ghofrane

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.
KOkte.1
KOkte.1Author
Associate
April 4, 2023

Hello Ghofane,

thank you very much for your response and interest.

I figured out by chance that without even assigning USB to these pins, USB is assigned.

I think the default assignment of these pins is USB. But I'm not sure.

But it would be better to see this assignment somewhere in the code. Because it becomes confusing this way.

On the topic of USB being not detected.

I figured that the VBUS needs to be detected by the microcontroller to to be detected by the PC.

This is stated in the USB FS specification. And in STs AN4879, USB hardware and PCB guidelines using STM32 MCUs.

Also in a forum, I read something like this.

disable VBUS activation, set PA9 output and set it to default High.

https://electronics.stackexchange.com/questions/251856/usb-on-stm32f107rct-and-stm32cubemx

When I did these steps the microcontroller is detected as a USB device by the PC.

But I think the safest option is to sense the VBUS.