STM 32F4xx - a general Q on I/O pins and AF config

There is a lot of this on various forums but few clear answers.

Let's say you set up PA9 to be an output. Then you set AF10 for that pin (alternate function 10 - USB FS).

In this mode that pin is used to sense the Vbus +5V, so if you are a USB Slave this produces an interrupt on the insertion of the USB lead from a PC.

This then starts the USB code running. And this code (like ethernet and most of the other drivers which STM provide with their development kits) is so complicated that nobody can understand it, so I think very few people ever start digging into it.

The Q I have is whether the chip designer put in specific logic which overrides the previous pin config.

For example the USB ID pin PA8 is supposed to have a pullup. Searching online suggests the recommended value is about 10k. Presumably the USB module has a pullup in it, and that would appear in parallel with any pullup configured conventionally on PA8?

Take this general doc

formatting link

Page 9 suggests that NO override is implemented, so if you config a pin to a push pull output, but the AF requires an input, you will break things.

On page 12 they say

When the I/O port is programmed as alternate function mode:

I think they really mean:

If the pin is an input on the AF, you can set the pin to input or (rather pointlessly) an open drain output (if the latter, write a 1 to it). And if it is an output on the AF, you can set the pin to open drain or push pull output, and setting it to an input will break it.

OTOH on the same page, 3.3.4, they say

When the I/O port is programmed in an analog configuration:

for every analog value of the I/O pin.The output of the Schmitt trigger is forced to a constant value (0).

so there they DO an override of the pin config, to some extent...

My example of PA9 at the top is actually a special case, because they bodged that one by connecting the USB module's Vbus sense directly to the package pin, regardless of any AF on PA9. Also the STM devt kits connect the USB +5V straight to that pin, violating the +4V 5VT pin limit when chip VCC=0 (the correct way is apparently a 4k7/10k divider to feed PA9).

Reply to
Postman Pat
Loading thread data ...

Why don't you try it out and report back?

--
 Thanks, 
    - Win
Reply to
Winfield Hill

Not really the right way to do it, given that lots of wrong combinations will still function.

Reply to
Postman Pat

Is this a crosspost? Why isn't the OP's question shown here? Did you reply to the wrong group?

--

  Rick C. 

  - Get 1,000 miles of free Supercharging 
  - Tesla referral code - https://ts.la/richard11209
Reply to
Rick C

My original post (nothing crossposted by me):

There is a lot of this on various forums but few clear answers.

Let's say you set up PA9 to be an output. Then you set AF10 for that pin (alternate function 10 - USB FS).

In this mode that pin is used to sense the Vbus +5V, so if you are a USB Slave this produces an interrupt on the insertion of the USB lead from a PC.

This then starts the USB code running. And this code (like ethernet and most of the other drivers which STM provide with their development kits) is so complicated that nobody can understand it, so I think very few people ever start digging into it.

The Q I have is whether the chip designer put in specific logic which overrides the previous pin config.

For example the USB ID pin PA8 is supposed to have a pullup. Searching online suggests the recommended value is about 10k. Presumably the USB module has a pullup in it, and that would appear in parallel with any pullup configured conventionally on PA8?

Take this general doc

formatting link

Page 9 suggests that NO override is implemented, so if you config a pin to a push pull output, but the AF requires an input, you will break things.

On page 12 they say

When the I/O port is programmed as alternate function mode:

I think they really mean:

If the pin is an input on the AF, you can set the pin to input or (rather pointlessly) an open drain output (if the latter, write a 1 to it). And if it is an output on the AF, you can set the pin to open drain or push pull output, and setting it to an input will break it.

OTOH on the same page, 3.3.4, they say

When the I/O port is programmed in an analog configuration:

for every analog value of the I/O pin.The output of the Schmitt trigger is forced to a constant value (0).

so there they DO an override of the pin config, to some extent...

My example of PA9 at the top is actually a special case, because they bodged that one by connecting the USB module's Vbus sense directly to the package pin, regardless of any AF on PA9. Also the STM devt kits connect the USB +5V straight to that pin, violating the +4V 5VT pin limit when chip VCC=0 (the correct way is apparently a 4k7/10k divider to feed PA9).

Reply to
Postman Pat

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.