STM32L433 USB two PIN connection (PA11 & PA12) Topic is solved

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: RoccoMarco, barthess

User avatar
Skadi
Posts: 60
Joined: Fri Apr 17, 2015 5:10 pm
Has thanked: 4 times
Been thanked: 3 times

STM32L433 USB two PIN connection (PA11 & PA12)

Postby Skadi » Thu Apr 05, 2018 9:06 pm

Hi,

I'm planning to establish an USB connection with a STM32L433. To keep the size of my PCB small, I want to use the LQFP-48 package. By having a look at my former projects using a STM32F407 discovery board, I noticed the pins PA2 and PA3 have to be remaped, as there alternate function includes USART_RX and USART_TX. The following lines are from ARMCM4-STM32F407-DISCOVERY-MEMS:

Code: Select all

/*
 * Activates the serial driver 2 using the driver default configuration.
 * PA2(TX) and PA3(RX) are routed to USART2.
 */
sdStart(&SD2, NULL);
palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7));
palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7));

So my question is, do I need four pins to establish an USB connection (PA2, PA3, PA11, PA12). By remapping PA2 and PA3, I think this two pins can not be used as GPIO pins e.g. as an INPUT ot OUTPUT.

So is there a possebility to establish the USB connection only with PA11 and PA12, as it is shown in the datasheet in appendix A.1? I haven't found an example without the pin remapping. If not, I have to use an other package, because I need this two additional pins.

BR

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: STM32L433 USB two PIN connection (PA11 & PA12)

Postby Giovanni » Thu Apr 05, 2018 10:23 pm

Never tried it...

Giovanni

User avatar
Skadi
Posts: 60
Joined: Fri Apr 17, 2015 5:10 pm
Has thanked: 4 times
Been thanked: 3 times

Re: STM32L433 USB two PIN connection (PA11 & PA12)

Postby Skadi » Fri Apr 06, 2018 10:04 am

Hi Giovanni,

thank you for your reply. I will make a further research. If I can manage a "two pin" connection, I will post my solution.

BR

rew
Posts: 380
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 13 times

Re: STM32L433 USB two PIN connection (PA11 & PA12)

Postby rew » Sat Apr 07, 2018 10:06 am

For USB you just need PA11 and PA12. Two pins, not more. There is something called a "physical layer", that says things about drive strength of the pins on the CPU. The "special pads" that have the right specs for USB are those marked "PA11" and "PA12". No other pin on the CPU can take that function because it doesn't have the hardware to do the right drive strength tricks. So while normally you'd switch a pin to AF mode and select the right AF to enable a module to use a pin, in this case, once you enable the USB module, PA11 and PA12 automatically are "hijacked" by the USB module. input/output mode or AF doesn't matter.

User avatar
Skadi
Posts: 60
Joined: Fri Apr 17, 2015 5:10 pm
Has thanked: 4 times
Been thanked: 3 times

Re: STM32L433 USB two PIN connection (PA11 & PA12)  Topic is solved

Postby Skadi » Sun Apr 15, 2018 11:36 pm

Hi rew,

thank you for your answer. I know, theortically I only need PA11 and PA12 to create an USB connection. I also know, that the controller has an internal PHY, enabling a USB FULL SPEED connetion (for HIGH SPEED an external PHY is required).

It is clear for me, that I have to configure PA11 and PA12 with their alternate function (10). I was just confused by the code snippet I already posted.

Code: Select all

/*
 * Activates the serial driver 2 using the driver default configuration.
 * PA2(TX) and PA3(RX) are routed to USART2.
 */
sdStart(&SD2, NULL);
palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7));
palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7));

This code is from the RMCM4-STM32F407-DISCOVERY-MEMS example, and for me it looks like PA2 and PA3 have to be configured to PAL_MODE_ALTERNATE(7) to establish an USB connection.

However, I managed to create an USB connection without setting e.g. PA2 and PA3 to their alternate function. Therefor I had a look to the USB example in chibios182\testhal\STM32\STM32F4xx\USB_CDC_IAD.

To be sure everything really works as desired :D, I configured the pins PA2, PA3, PA15 (USART2_TX/RX), PA9, PA10, PB6, PB7 (USART1_TX/RX) and PB10, PB11 (USART3_TX/RX) as input or output pins, after the USB connection is started. Everything works fine, so far. So it seems the code example in chibios182\testhal\STM32\STM32F4xx\USB_CDC_IAD doesn't require any further alternate pin configurations, by means of an additional USART.

BR

rew
Posts: 380
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 13 times

Re: STM32L433 USB two PIN connection (PA11 & PA12)

Postby rew » Mon Apr 16, 2018 9:02 am

On older chips the USB would take over the pin without further involvement from you. It seems that USB is now a proper AF. So you need to set PA11 and PA12 to AF10 to enable USB.

You do NOT need to configure PA2 and PA3 to AF7 to enable USB. There are several reasons for this.
1) These pins have nothing to do with USB.
2) You can use them for whatever you want. USART if you want (AF7) but also TIM2 or simply GPIO.

Maybe the example demos that you can use them for serial communication, but it has nothing to do with USB on the other pins.

you have several USART modules inside your CPU. They have NOTHING to do with the USB module. They are completely independent.


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 56 guests