2012-08-09 01:52 AM
Hello,
One simple question please: Why It is mandatory to Set PA11/PA12 for USB data (+/-) as Alternate Function (AF) ? in STM32F103 for example I’m asking this because in other products such as STM32L , it working even without putting them as “AF� Could You please help me Abdul2012-08-09 05:05 AM
It likely depends on the default settings for the GPIO/AFIO, or other registers in the design.
When AF mode is enabled and routed, it changes the function of the IO cell and disconnects the GPIO output control. It is always a good plan to explicitly define/set the functionality you want rather than assume initial conditions.2013-02-02 12:16 AM
Dear clive1,
Now I am testing the STM32L151CB USB section. Can we require USB D+ and USB D- pin should be Alternate Function(AF)? Can i have any example code using USB as Alternate function? I have checked the USB mass storage example, but i got USB not detected. Can you help me for this problem. Thanks Arul2013-02-02 01:44 AM
Looking at the manuals, one could assume that the pins do NOT default as AF/USB, but there is no code in the examples to change this.
I would expect the following code would address that ambiguity.void PinConfigUSB(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_USB);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_USB);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;
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);
}
2013-02-03 08:06 PM
Dear clive1,
Thanks for your Response. I do the test and come back to you. Thanks Arul2013-02-04 01:35 AM
Hi clive1,
Still the problem is not solved. I found that we have to disable USB internal pull up before use external pull up. Thanks Arul2013-02-04 08:50 PM
Hi Abdul,
You mentioned that the STM32L usb section is working without configure as ''AF'' Do you have working example code to test STM32L USB functionality? Thanks Arul2013-02-05 08:48 AM
I've posted ported code of KEIL RL-USB HID for STM32L-DISCOVERY
http://www.keil.com/forum/22234/ Without alternate function setting, the USB D+/D- ports work, just upon the default setting. In above post, brief porting steps from STM32F103 to STM32L15x are described. It'll help you to find clues of your problem. Tsuneo2013-02-05 09:00 PM
Hi all,
Thanks for everyone response. Now STM32L151CB usb is working well. We need not to configure as ''USB AF'' Actual problem in my custom PCB side.Some resistor affected the usb Pins. After remove it , it is working well. You may disable the USB internal pull up before using External pull up. Thanks Arul2014-01-27 12:59 PM
Hello Clive1
Actually, the Reference Manual RM0008 (Doc ID 13902 Rev 10) says that PA11 and PA12 are automatically connected to the USB transceiver when USB is enabled. Thus, there is no need for your code for this.Regards,Peter