Skip to main content
FLewz.1
Associate III
May 8, 2020
Solved

STM32F446RE Can't use Pins PA2, PA3 as Input

  • May 8, 2020
  • 7 replies
  • 3256 views

Hi,

I am trying to use the PA2 and PA3 Pins among others as Inputs with Pullups. The configuration is correct, since I am comparing what is in the GPIO Registers for Port A with another input pin PA8 which works fine. I have seen that the same pins use serial and analog input, however I have not initialized serial and I guess to use the analog input you have to initialize it in the mode register? I am using the ADC but I have not configured these pins for analog input.

Am I missing something, that is keeping me from using these pins?

This topic has been closed for replies.
Best answer by waclawek.jan

Manipulate the PA2/PA3 pins while observing GPIOA_IDR in the debugger.

Is this a "known good" board such as a Nucleo64?

What's connected to those pins? (If it's Nucleo64, then disconnect the STLINK VCP connections, SB13, SB14, and connect SB62, SB63, see UM1724).

JW

7 replies

Uwe Bonnes
Chief
May 8, 2020

Analog input with internal PullUP is marked as reserved.

FLewz.1
FLewz.1Author
Associate III
May 8, 2020

So using an external pullup would solve my problem?

waclawek.jan
Super User
May 8, 2020

Please state clearly, what do you intend to do, and how the present state is different from your expectations.

Do this together with posting the relevant GPIO registers' settings.

JW

FLewz.1
FLewz.1Author
Associate III
May 8, 2020

I am trying to use PA2 and PA3 as inputs with pullups, to register when it gets pulled low. Now it doesn't register when pulled low.

GPIO_InitStruct.Pin = IN0_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(IN0_PORT, &GPIO_InitStruct);

That's the InitStruct with IN0_PIN being GPIO_PIN_2 and IN0_PORT being GPIOA.

The same struct is being used on pin PA8 for example, where it works and the pin successfully reads as GPIO_Pin_RESET when pulled low.

waclawek.jan
waclawek.janBest answer
Super User
May 8, 2020

Manipulate the PA2/PA3 pins while observing GPIOA_IDR in the debugger.

Is this a "known good" board such as a Nucleo64?

What's connected to those pins? (If it's Nucleo64, then disconnect the STLINK VCP connections, SB13, SB14, and connect SB62, SB63, see UM1724).

JW

FLewz.1
FLewz.1Author
Associate III
May 8, 2020

Yes it's a nucleo board. But your hint to the User Manual solved my problem, since those are the two UART pins, although I figured disabling UART2 would suffice. Unfortunately I'll have to rethink my external hardware connection.

Thank you!