Skip to main content
ACots.1
Associate
July 28, 2020
Question

STM32L0x2: How to use PH0 for external clock and PH1 as GPIO?

  • July 28, 2020
  • 3 replies
  • 1461 views

Hi,

I’m working on a board with an STM32L072RZ. I have and external clock source connected to PH0. And I want to use PH1 as GPIO. According to the Reference Manual RM0376 at section 9.3.13 this should be possible. But in section 7.2.1, the document also says that “the OSC_OUT pin should be left hi-Z (see Figure 40).�?. But in Figure 40 there’s written GPIO in OSC_OUT. I’ve tried to use PH1 both as output and input but it doen’t work.

The initialitation is made with STM32CubeMX v5.6.1.

I checked RCC_CR register and bit HSEBYP and HSEON are being SET.

When I use PH1 as output and I set it HIGH in main(), I can see that bit OD1 of GPIOH_ODR register is correctly set. But the pin remains LOW (oscilloscope).

When I use PH1 as input, even if I pull the pin HIGH, the ID1 bit in GPIOH_IDR register does not change.

I also tried to use the internal clock and PH1 works so it’s not broken.

Any ideas? Thank you very much for the support.

Aléxandros

This topic has been closed for replies.

3 replies

Tesla DeLorean
Guru
July 28, 2020

I know of a board where this was tried and didn't work. Would not recommend.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
MM..1
Super User
July 28, 2020

Have you GPIOH port clock enabled?

ACots.1
ACots.1Author
Associate
July 29, 2020

Yes,

__HAL_RCC_GPIOH_CLK_ENABLE();