2011-08-12 01:10 AM
Hello,
I am working on USB applications on a STM32F207IG. The usb communication works in FS with the port PA9, PA11 and PA12, in HS with the ULPI. But I need to USE the ports PB13 (Vbus) , PB 14 (DM) and PB15 (DP). They are HS pins configured in FS mode.
Here how I configured these pins:
RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOB, ENABLE ); GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; //Configure VBUS DM DP Pins GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15; GPIO_Init( GPIOB, &GPIO_InitStructure ); GPIO_PinAFConfig( GPIOB, GPIO_PinSource13, GPIO_AF_OTG2_FS ); // vbus GPIO_PinAFConfig( GPIOB, GPIO_PinSource14, GPIO_AF_OTG2_FS ); // D- GPIO_PinAFConfig( GPIOB, GPIO_PinSource15, GPIO_AF_OTG2_FS ); // D+ RCC_APB2PeriphClockCmd( RCC_APB2Periph_SYSCFG, ENABLE ); RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_OTG_HS, ENABLE );
Unfortunatly, it is not working. Can you help me ?
Thank you.
#stm32-usb2011-08-15 11:55 PM
Does anybody see what's wrong ? I really need help. Please.
2011-08-23 06:35 AM
Hi
I also tried to use the OTG_HS periphery in device FS mode (internal FS Phy ) with the ST USB library ( STM32F205VB). The device example code does the equvalent pin initialisation as was shown in the erlier post. But there seems to be a problem with the VBUS pin (BP13) initialisation. If I define the VBUS pin as push pull and select the alternat function. The current flowing into the VBUS pin is 45mA or more. I guess the pin is configured as OTG_HS_ULPI_D6. Does anybody know how to connect the PB13 to the OTG_HS VBUS functionality? regarsd Raphael2011-08-23 06:50 AM
Does anybody see what's wrong ? I really need help. Please.
Perhaps you want to put this line before you remap it?RCC_APB2PeriphClockCmd( RCC_APB2Periph_SYSCFG, ENABLE );
2011-08-24 05:04 AM
Hi
I fugured out, what the problem was. It was a initialisation probelm of pin PB13 (VBUS) and a hardware problem of our board. The initialisation of PB13 which seems to work for me looks like this:// Enable GPIO clocks (note: done at Gpio.c)
//RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB , ENABLE); // Init USB DN and DP pins GPIO_InitStructure.GPIO_Pin = PB_USB_DN | PB_USB_DP; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOB, &GPIO_InitStructure); // Connect pins to alternate function GPIO_PinAFConfig(GPIOB, GpioPinNumGet( PB_USB_DN ), GPIO_AF_OTG2_FS); GPIO_PinAFConfig(GPIOB, GpioPinNumGet( PB_USB_DP ), GPIO_AF_OTG2_FS); // Init USB VBUS pins (note: has to be defined as GPIO_Mode_IN instead of GPIO_Mode_AF) GPIO_InitStructure.GPIO_Pin = PB_USB_VBUS; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; GPIO_Init(GPIOB, &GPIO_InitStructure); // Connect pins to alternate function GPIO_PinAFConfig(GPIOB, GpioPinNumGet( PB_USB_VBUS ), GPIO_AF_OTG2_FS); // Enable OTG_HS clock RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_OTG_HS, ENABLE) ; Defining PB13 (PB_USB_VBUS) as input instead of alternate output solved the current flowing into this pin. An injection current which flowed through an ESD diode to PB13 leaded to an instable sensing of VBUS. regards Raphael