cancel
Showing results for 
Search instead for 
Did you mean: 

USB Power switch on ERROR in CUBEMX software?

HKnoe.1
Associate

I have tried to get the USB FatFS MSC example for Nucleo 144 - STM32F429ZI working. After about 10 day I have succeeded, but I had to change the MX_DriverVbusFS in the usbh_platform.c file as follows:

original code:

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_SET;

 }

 else

 {

   /* Drive low Charge pump */

   data = GPIO_PIN_RESET;

 }

 /* USER CODE END PREPARE_GPIO_DATA_VBUS_FS */

 HAL_GPIO_WritePin(GPIOG,GPIO_PIN_6,(GPIO_PinState)data);

}

WORKING code :

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(GPIOG,GPIO_PIN_6,(GPIO_PinState)data);

}

I do not understand: the comment in the code says:

/**

 * @brief Drive VBUS.

 * @param state : VBUS state

 *         This parameter can be one of the these values:

 *          - 0 : VBUS Active

 *          - 1 : VBUS Inactive

 */

which seems to be the NOT working code. Looking at the schematics, imo, an active high signal on USB Power Switch ON will put voltage on the VBUS. What am I missing, or is the comment in the code in error?

Henk

1 REPLY 1

Hi @HKnoe.1​ 

Could you please share your .ioc file to check with.

Best regards,

Nesrine