2022-02-22 12:08 PM
I'm setting out to configure I2C2 on STM32F051R8.
RM0091 (dm00031936) table 13 (pin definitions) has two rows describing pin 47/48 (LQFP64 package) PF6 and PF7 as being configurable for I2C2_SCL and I2C2_SDA.
I'm now looking for alternate function (AF) configuration for GPIOF to expose I2C2 on those two pins, but cannot find any (there are no other references to PF6 and PF7 anywhere in the document.
I've looked through RM0091 and cannot find any description of how PF6/PF7 is connected to I2C2_SCL and I2C2_SDA.
Does lack of presence in GPIO Alternate Function mean that the only functions supported by PF6/PF7 are GPIO or I2C2, so there is no need to do anything but enable I2C2 and it will then appear on those two pins? If I enabled I2C2 intending to send it to PB10/PB11, will it also appear on PF6/PF7 as a side-effect?
I'm using neither HAL nor LL for this experiment - I'm generating register configurations by hand (as a learning experience).
Thanks for any advice!
2022-02-22 12:18 PM
My guess as they are a singular function of the pin in AF mode, there isn't an AF MUX to select between other options.
ie you configure the GPIO in AF mode, and it takes the AF function (singular) assignment.
>>If I enabled I2C2 intending to send it to PB10/PB11, will it also appear on PF6/PF7 as a side-effect?
Look there is a specific AF selection method for the GPIO pin, can you create conflicts, probably, but you'd have to try and create them, and they can be entirely avoided.
2022-02-22 12:41 PM
Makes sense - usually the STM32 stuff seems to be very well thought through, however, in this case if I want I2C2 I should dedicate PF6/PF7.
2022-02-22 12:50 PM
Or use PB10/PB11, or some combination of the pins.
If you use PF6/PF7 you can use PB10/PB11 as a Generic GPIO, or one of the other Alternate Function mappings.
2022-02-22 01:38 PM
Yes makes sense - I am new to the STM32 ecosystem and this is the first time I'd encountered a situation where a peripheral had somewhat exclusive assignment to port pins. This causes no problem now as I'm just experimenting - I just wanted to be sure I was reading the documentation correctly as it seemed at first that some information might be missing, which is not the case.
Thanks again for your advice!
Dave
2022-02-22 03:36 PM
Feels like it's missing information in the datasheet. The GPIOF register has AF fields same as other ports.
Almost certainly you need to set the pins in AF mode, otherwise they will be in default GPIO configuration, either input or analog depending on the family.
FWIW, CubeMX doesn't initialize the AF field for those pins during initialization. Maybe it works, maybe not.