cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F401 - using OSC_IN/OSC_OUT as GPIO

kla
Associate

Hello,

I am having trouble in getting PC14 and PC15 working as GPIOs on the STM32F401. The reference manual says that "The LSE oscillator pins OSC32_IN and OSC32_OUT can be used as general-purpose PC14 and PC15 I/Os, respectively, when the LSE oscillator is off.". However I still cannot use them as GPIOs, despite disabling LSE. I am aware of the current limit and the backup power domain. In my design Vbat is connected directly to Vdd and I enabled the backup power domain in RCC. Is there some special mode that they need to operate?

My design uses external 24kohm pullup resistors on these pins, because I read in the manual that they can only sink current.

Currently, my init code does (in the following order):

  • enables backup power
  • enables access to RTC registers, sets RTC_CR to zero and backup RTC_CR to zero
  • resets backup domain: sets RCC_BDCR |= (1<<16); waits a while, and sets RCC_BDCR &= ~(1<<16);
  • enables GPIOC in RCC and sets all pins of GPIOC to be outputs, with internal pullups enabled, slew rate 2MHz, push-pull mode

In this case toggling the GPIOC makes all pins but PC[13-15] change state. Is there something I am missing?

According to the datasheet woding all that RTC code should not be necesary because the LSE is disabled by default

Does anyone have a code example (CubeMX or Libopencm3) which shows how to control these pins?

 

Best Regards

KL

1 ACCEPTED SOLUTION

Accepted Solutions
RomainR.
ST Employee

Hi @kla 

If you need to use PC13, PC14 and PC15 as GPIOs output with VBAT connected to VDD there is a Power switch in VBAT domain that limit the sinks current to 3mA.

So, the usage of PC13 to PC15 is restricted with maximum speed 2MHz and an external maximum load 30pF.

Check the RM0368 Rev 5 5.1 Power supplies section.

In your case, I do not understand why your are enabling power domain and access to RTC registers?

You just have to configure PC13 to PC15 in GPIO Output with GPIO_SPEED_FREQ_LOW (2MHz)

I share with you a CubeIDE project that does this. Can you check please?

Let me know if it helps you?

Best regards.

Romain,

 

 

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

2 REPLIES 2
RomainR.
ST Employee

Hi @kla 

If you need to use PC13, PC14 and PC15 as GPIOs output with VBAT connected to VDD there is a Power switch in VBAT domain that limit the sinks current to 3mA.

So, the usage of PC13 to PC15 is restricted with maximum speed 2MHz and an external maximum load 30pF.

Check the RM0368 Rev 5 5.1 Power supplies section.

In your case, I do not understand why your are enabling power domain and access to RTC registers?

You just have to configure PC13 to PC15 in GPIO Output with GPIO_SPEED_FREQ_LOW (2MHz)

I share with you a CubeIDE project that does this. Can you check please?

Let me know if it helps you?

Best regards.

Romain,

 

 

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Thank you @RomainR., using your Cube example I was able to implement it in my code!

My initial attempts at disabling the RTC and so on were my misunderstanding and trying to get something to work.