cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F446RE Can't use Pins PA2, PA3 as Input

FLewz.1
Associate III

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

7 REPLIES 7
Uwe Bonnes
Principal III

Analog input with internal PullUP is marked as reserved.

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

So using an external pullup would solve my problem?

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.

To add the register values after configuration:

MODER2 0x0
MODER3 0x0
 
PUPDR2 0x1
PUPDR3 0x1
 
IDR3 0x1
IDR2 0x1

The other registers are at reset value, so no alternate function mapping or anything.

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

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!