cancel
Showing results for 
Search instead for 
Did you mean: 

Bug with Mx_driverVbusFs when generating the code and how to fix it

sAlsa.1
Associate II

Hi,

Iam student on Sheffield hallam university an​d I called by sulaiman Alsaffar discover bug when working on stm32f407 discovery board.

This bug set the 5v for the vbus low which make it unactive in patch 6.4.0 .I had to read all folder that generate by the mx usb drive to fix this problem since it wont let you use usb because it wont get enough voltage and it not mentioned anywhere and wasn't there before.

​Fixing the issue with USB MSC

The USB Mass Storage Class was not working because of insufficient voltage supply to

VBUS. It was figured out that the usbh_platform.c file generated by the CubeMX software was

having issues.

By making necessary modifications, the expected outcome was obtained.

Before fix

/**

*@brief Drive VBUS.

* @param state : VBUS state

* This parameter can be one of the these values:

* -1: VBUS Active

* -0 : VBUS Inactive

*/

void MX_DriverVbusFS(uint8_t state)

{

uint8_t data - state;

/* USER CODE BEGIN PREPARE_GPIO_DATA_VBUS_FS */

if(state == 0)

{

/* Drive high Charge pump */

data - GPIO PIN_RESET;

}

else

{

​/* Drive low Charge pump */

data - GPIO_PIN_SET;

/* USER CODE END PREPARE_GPIO_DATA_VBUS_FS */

HAL_GPIO_WritePin(GPIOC, GPIO_PIN_O, (GPIO_PinState)data);

​After the fix

/**

*@brief Drive VBUS.

* @param state : VBUS state

* This parameter can be one of the these values:

* -1: VBUS Active

* -0 : VBUS Inactive

*/

void MX_DriverVbusFS(uint8_t state)

{

uint8_t data - state;

/* USER CODE BEGIN PREPARE_GPIO_DATA_VBUS_FS */

if(state == 1)

{

/* Drive high Charge pump */

data - GPIO PIN_RESET;

}

else

{

​/* Drive low Charge pump */

data - GPIO_PIN_SET;

/* USER CODE END PREPARE_GPIO_DATA_VBUS_FS */

HAL_GPIO_WritePin(GPIOC, GPIO_PIN_O, (GPIO_PinState)data);

I hope you find this helpful 🙂

Sincerely appreciate for your read and effort.​

1 ACCEPTED SOLUTION

Accepted Solutions
sAlsa.1
Associate II

and this my fix for it

View solution in original post

4 REPLIES 4

Hello @sAlsa.1​ 

In order to allow a better analysis of this problem, could you please share your project to reproduce the issue?

Thanks in advance.

BeST Regards,

Walid

sAlsa.1
Associate II

Hello Walid

this the src file for the project which has problem in usbh_platform.c

Thanks in advance.

BeST Regards,

sAlsa.1
Associate II

and this my fix for it

Hello @sAlsa.1​,

Good news! Thank you for sharing the fix 😊

BeST Regards,

Walid