AnsweredAssumed Answered

How to configure an GPIO Input port: NoPull,PullUp,PullDown ??

Question asked by rupprath.marc on Feb 9, 2013
Latest reply on Feb 10, 2013 by Andrew Neil
Hello;
i have problems to understand how to configure an GPIO input port correctly.

What i wan't:
Port PA5 shall be configured als input port.
A simple switch is conected between the +5V source and the input pin.
The desired behaviour:
Input PA5 is "high" when switch is closed
Input PA5 is "low" when switched is opened
i tried to configure the port as follows:

.....

 

 

GPIOA_InitSTructure.

GPIO_Pin = GPIO_Pin_5;
GPIOA_InitSTructure.
GPIO_Mode = GPIO_Mode_IN;
GPIOA_InitSTructure.
GPIO_OType = GPIO_OType_PP;
GPIOA_InitSTructure.
GPIO_PuPd = GPIO_PuPd_DOWN;

/*GPIOA_InitSTructure.GPIO_PuPd = GPIO_PuPd_NOPULL*/;
GPIOA_InitSTructure.GPIO_PuPd = GPIO_PuPd_UP;

 

 

GPIOA_InitSTructure.

GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIOA_InitSTructure);

 


The problem:
The Port is always high, even when the switch is open or not connected to Port .I tried all 3 combinations: PullUp, Pull Down,NoPull

What wen't wrong and how to configure the ports correctly ?
I am using a Waveshare Open407Z Board with
STM32F407ZGT6 Processor

Thanks in advance.

Marc



Outcomes