2015-08-18 05:50 AM
Hi all,
in another Thread it is mentioned and confirmed that bootloader v2.0 will configure the stm32f105/7 devices usart1 in a way that vbus detection pin pa9 will draw about 45ma. (/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32F105%20PA9OTG_FS_VBUS%20Issues&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=1763
)I am working with a STM32F407 and experiencing more or less the same, but not just using the bootloader but whenever i configure the usb to monitor pa9. I tried this with 2 different projects, same behaviour. Finally i tried the discovery board, same here with the provided codeexamples. demonstration demo: ~85ma, Audio usb playback demo:~130ma, after cutting the VBUS/PA9 line: ~90ma. Since on 2 of my STM32F407 PA9 is now internally shorted to VCC this seems to be a rather serious issue (with 25 max allowed sinking current for io pins ).Can anyone confirm this error? Is there any workaround ( i could configure the pin as input and monitor it myself, but would be nice to use the hardware and not mess around with the usb code ) null2015-08-19 09:54 AM
If anyone is interested it seems I found the solution in another thread (
). If initialized as AF Pin there seems to be a bug that leads to a current of 45mA being drawn while working as expected (if it doesn't burn and short to vcc like mine ). If configuring as input with pulldown but setting afrh to 0xa ( af usb otg fs ) results in no more current flow. But if I connect and disconnect USB there will be a voltage of 2.1V and no detection that the cable ( and external voltage ) are gone. Shorting VBUS to Ground for a quick moment lets the voltage disappear and the device detects the missing VBUS voltage. Instead of shorting I tried 10K external pulldown - no effect. Switching to 1k external pulldown: Voila, no excessive currents, full functionality. But: could anyone explain why this is working? Info for the board: USB connected to USB6b1RL transient protection connected to STM32F407 like in the DiscoveryF4 board.2015-08-19 10:25 AM
> If initialized as AF Pin there seems to be a bug that leads to a current of 45mA being drawn while working as expected (if it doesn't burn and short to vcc like mine ).
Why would that be a bug? The datasheet clearly states that OTG_FS_VBUS is an additional function on PA9, *not* an AF. I am no expert on USB, but this is a complex OTG implementation and you should read thoroughly the relevant chapters of manual, it appears to deal with VBUS extensively. JW2015-08-19 10:36 AM
Well then at least the sample code does not pay tribute to that:
( Discovery F4 Demonstration usb_bsp.c )GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 |
GPIO_Pin_9 |
GPIO_Pin_11 |
GPIO_Pin_12;
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 ;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOA,GPIO_PinSource8,GPIO_AF_OTG1_FS) ;
GPIO_PinAFConfig(GPIOA,GPIO_PinSource9,GPIO_AF_OTG1_FS) ;
GPIO_PinAFConfig(GPIOA,GPIO_PinSource11,GPIO_AF_OTG1_FS) ;
GPIO_PinAFConfig(GPIOA,GPIO_PinSource12,GPIO_AF_OTG1_FS) ;
2015-08-20 02:38 AM
You are right with the additional function vs alternative function. But after crawling through the different datasheets / reference manuals i was not able to find any information about how to configure a pin correctly for an additional function.
The only information I found was in . But in only states that ''Alternate functions: Functions selected through GPIOx_AFR registers. Additional functions : Functions directly selected/enabled through peripheral registers.''. Since I have to set the AFRH register to 10 for it to work (wich is an empty field in the alternate function table ) there has to be some error or at least something missing in the documentation. Since the sample code and the datasheet do not show how it is intended to be used ( sample code is *wrong* and may damage the board!) I would be glad to here some official statement.2015-08-21 04:34 AM
2015-08-21 08:34 AM
> Got response from ST: the demo code is wrong.
Are we talking about STM32F4-Discovery_FW_V1.1.0 ? That's sad. I had a look into STM32_USB-Host-Device_Lib_V2.1.0 - some of the examples do it exactly as the discovery example, some set VBUS as input (which is superfluous as it's the reset setting): /* Configure SOF VBUS ID DM DP Pins */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_11 | GPIO_Pin_12; 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 ; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; GPIO_Init(GPIOA, &GPIO_InitStructure); > The voltage after disconnecting comes from the ESD protection. STM32 is driving D+/D- to ~3 Volt once USB communcation started, > so the diodes in USB6B1 feed the vbus line backwards if USB active but cable pulled out The USB6B1 (and similarly built protection ICs) is not adequate for this purpose, then, and this is a snippet of information good to know, thanks. The DISCO and EVAL boards use EMIF02-USB03F2, which is built from bipolar transils only, clamping all the lines to ground with some 14V breakdown (and it's a BGA-style bare chip...) Now the question might be how efficient such protection (together with the internal diodes in the mcu) is... JW