cancel
Showing results for 
Search instead for 
Did you mean: 

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

ACots.1
Associate

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

3 REPLIES 3

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
Up vote any posts that you find helpful, it shows what's working..
MM..1
Chief II

Have you GPIOH port clock enabled?

Yes,

__HAL_RCC_GPIOH_CLK_ENABLE();