Specifically, an STM32F051 has some limitations on pins also used for the 32 kHz "LSE":
- PC13, PC14 and PC15 are supplied through the power switch. Since the switch only sinks a limited amount of current (3 mA), the use of GPIOs PC13 to PC15 in output mode is limited:
- The speed should not exceed 2 MHz with a maximum load of 30 pF.
- These GPIOs must not be used as current sources (e.g. to drive an LED).
- After the first RTC domain power-up, PC13, PC14 and PC15 operate as GPIOs. Their function then depends on the content of the RTC registers which are not reset by the main reset. For details on how to manage these GPIOs, refer to the RTC domain and RTC register descriptions in the reference manual.
This seems to mean that these pins can only sink a combined 3 mA, so they must be configured as open drain only, not as push-pull?
The reference manual says
When PC13 is not used as RTC alternate function, it can be forced in output push-pull mode by setting the PC13MODE bit in the RTC_TAFCR. The output data value is then given by the PC13VALUE bit. In this case, PC13 output push-pull state and data are preserved in Standby mode. The output mechanism follows the priority order shown in Table 80. When PC14 and PC15 are not used as LSE oscillator, they can be forced in output push-pull mode by setting the PC14MODE and PC15MODE bits in the RTC_TAFCR register respectively. The output data values are then given by PC14VALUE and PC15VALUE. In this case, the PC14 and PC15 output push-pull states and data values are preserved in Standby mode. The output mechanism follows the priority order shown in Table 81 and Table 82.
The tables then show that with the respective bits set to zero the pin is a "Standard GPIO".
RTC_TAFCR then probably should be reset manually (before?) trying to configure it as GPIO output?
What are the implications for using it as an output, e.g. with an external mosfet - does this then have to be a p-channel with a pull-up resistor on its gate? As an input it could be used regularly, except that it's not five-volt tolerant?