cancel
Showing results for 
Search instead for 
Did you mean: 

Deinitialize USB_OTG_FS

Arsenii Soitu
Associate II
Posted on October 02, 2017 at 11:07

Hello!

I use cube usb library for usb_otg_fs mode wit STM32L467. I would like to use DM and DP pins also as GPIO INPUT PULL UP when usb is not used.

After usb connection closed, I do the following:

1) I use functions USBD_Stop and USBD_DeInit

2) Disable usb_otg_fs clock

2) Initialize DM and DP pins as GPIO INPUT PULL UP

But after these operations I cannot see high logic level on these pins. Maybe I didn't clear all necessary registers in usb_otg_fs? How should I properly deinitialize usb interface for using DM and DP pins as gpio?

Thank you

#stm32l4-usb #usb
1 ACCEPTED SOLUTION

Accepted Solutions
Arsenii Soitu
Associate II
Posted on October 05, 2017 at 10:00

So, if somebody will have such problem, i've managed with it. My method is not pretty cool, but it works. If you want to completely de-initialize usb to use DM and DP pins as gpio or in the other way you want, do the following:

1) USB_OTG_FS->GCCFG =   0x00000000; // Simply disable transciever/receiver option by setting PWRDWN bit to 0

2) USBD_Stop( &USBD_Dev );

3) USBD_DeInit( &USBD_Dev );

Steps 2 and 3 are default from ST usb library

You can also use the following method, but for me it was unnecessary:

1) USB_OTG_FS->GCCFG =   0x00000000; // Simply disable transciever/receiver option by setting PWRDWN bit to 0

2) USB_OTG_FS->GPWRDN = 0x00000010;

3) USB_OTG_FS->GADPCTL = 0x00000000;

4) USBD_Stop( &USBD_Dev );

5) USBD_DeInit( &USBD_Dev );

Steps 4 and 5 are default from ST usb library

Steps 2 and 3 simply reset configuration USB registers to default values

View solution in original post

1 REPLY 1
Arsenii Soitu
Associate II
Posted on October 05, 2017 at 10:00

So, if somebody will have such problem, i've managed with it. My method is not pretty cool, but it works. If you want to completely de-initialize usb to use DM and DP pins as gpio or in the other way you want, do the following:

1) USB_OTG_FS->GCCFG =   0x00000000; // Simply disable transciever/receiver option by setting PWRDWN bit to 0

2) USBD_Stop( &USBD_Dev );

3) USBD_DeInit( &USBD_Dev );

Steps 2 and 3 are default from ST usb library

You can also use the following method, but for me it was unnecessary:

1) USB_OTG_FS->GCCFG =   0x00000000; // Simply disable transciever/receiver option by setting PWRDWN bit to 0

2) USB_OTG_FS->GPWRDN = 0x00000010;

3) USB_OTG_FS->GADPCTL = 0x00000000;

4) USBD_Stop( &USBD_Dev );

5) USBD_DeInit( &USBD_Dev );

Steps 4 and 5 are default from ST usb library

Steps 2 and 3 simply reset configuration USB registers to default values