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:
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;
GPIO_Speed = GPIO_Speed_50MHz;
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
Thanks in advance.