We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Reply to ARM: Configuration USB ports http://www.keil.com/forum/19376/ - above thread is accidentally read-only
> Joseph Moschini: > I was wondering if this issue was ever solved ?, I am having the same problem on STM32F407.
Refer to the recent ST USB library,
STM32F105/7, STM32F2 and STM32F4 USB on-the-go Host and device library v2.1.0 www.st.com/.../stm32_f105-07_f2_f4_usb-host-device_lib.zip
ST USB stack supports all device engines, FS, FS on OTG_HS, ULPI on OTG_HS.
You'll find port pin setups in usb_bsp.c of each device project, for example, STM32_USB-Host-Device_Lib_V2.1.0\Project\USB_Device_Examples\AUDIO\src\usb_bsp.c Find USE_USB_OTG_HS and ! USE_ULPI_PHY macros.
Tsuneo
I managed to get it this work with keil library. I delved into the ST library and found a bit 6 in USB_HS_GUSBCFG needed to be set. Could not find any details of this configuration in the ST manual. I cannot find any errata documentation. Does anyone know where I get the any documentation with details of this hidden configuration.
Bit 6 PHYSEL on OTG_HS_GUSBCFG is described on STM32F2xx Reference Manual (RM0033, December 2011 rev4). But this bit is reserved on STM32F4xx Reference Manual (RM0090, September 2011 rev1) I believe the OTG_FS/OTG_FS cores are identical on these STM32 families.
Hi Joseph,
may I ask you if you can share your custom Keil driver for OTG_HS on PB14 and PB15, please? Best regards,
Lorenzo
I pasted the USBD_Init, that was the main change. If you want I can send files if needed.
/* * USB Device Initialize Function * Called by the User to initialize USB * Return Value: None */ void USBD_Init (void) { RCC->AHB1ENR |= (1UL << 1); /* PB12 OTG_HS_ID */ GPIOB->MODER = (GPIOB->MODER & ~(3UL << 24)) | (2UL << 24); GPIOB->OTYPER &= ~(1UL << 12); GPIOB->OSPEEDR |= (3UL << 24); GPIOB->PUPDR &= ~(3UL << 24); GPIOB->AFR[1] = (GPIOB->AFR[1] & ~(15UL << 16)) | (12UL << 16); /* PB14 DM */ GPIOB->MODER = (GPIOB->MODER & ~(3UL << 28)) | (2UL << 28); GPIOB->OTYPER &= ~(1UL << 14); GPIOB->OSPEEDR |= (3UL << 28); GPIOB->PUPDR &= ~(3UL << 28); GPIOB->AFR[1] = (GPIOB->AFR[1] & ~(15UL << 24)) | (12UL << 24); /* PB15 DP */ GPIOB->MODER = (GPIOB->MODER & ~(3UL << 30)) | (2UL << 30); GPIOB->OTYPER &= ~(1UL << 15); GPIOB->OSPEEDR |= (3UL << 30); GPIOB->PUPDR &= ~(3UL << 30); GPIOB->AFR[1] = (GPIOB->AFR[1] & ~(15UL << 28)) | (12UL << 28); /* PB13 VBUS */ GPIOB->MODER = (GPIOB->MODER & ~(3UL << 26)); GPIOB->OSPEEDR |= (3UL << 26); GPIOB->PUPDR &= ~(3UL << 26); RCC->AHB1ENR |= (1UL << 29); /* enable clk for OTGHS */ usbd_stm32_delay (1000); RCC->AHB1RSTR |= (1UL << 29); /* reset OTGHS clock */ usbd_stm32_delay (1000); RCC->AHB1RSTR &= ~(1UL << 29); usbd_stm32_delay (4000); OTG_HS->GUSBCFG |= (1UL << 30); /* force device mode */ usbd_stm32_delay (1000); OTG_HS->GUSBCFG |= (1UL << 6); usbd_stm32_delay (500); USBD_IntrEna(); /* Enable OTG interrupt */ // OTG_HS->GAHBCFG |= (1UL << 7); OTG_HS->GAHBCFG |= 1UL; // OTG_HS->GUSBCFG = (OTG_HS->GUSBCFG & ~(15UL << 10)) |(9 << 10);/*turnaround*/ // usbd_stm32_delay (500); OTG_HS->DCFG &= ~(3UL); OTG_HS->DCFG |= 1; // OTG_HS->PCGCCTL = 0; /* Restart PHY clock */ OTG_HS->GINTMSK = (1UL << 11) | /* suspend int unmask */ (1UL << 12) | /* reset int unmask */ (1UL << 13) | /* enumeration done int unmask */ (1UL << 4 ) | /* recive fifo non-empty int unmask */ (1UL << 18) | /* IN EP int unmask */ (1UL << 19) | /* OUT EP int unmask */ (1UL << 31) | /* resume int unmask */ #ifdef __RTX ((USBD_RTX_DevTask != 0) ? (1UL << 3) : 0); /* SOF int unmask */ #else ((USBD_P_SOF_Event != 0) ? (1UL << 3) : 0); /* SOF int unmask */ #endif }
Ouch! I need the driver for USB Host... I modified GPIO, RCC, IRQ as you done for USB device but it doesn't work. http://www.keil.com/forum/21431/
Anyway, thanks a lot!