AnsweredAssumed Answered

High values on unconnected GPIO pins

Question asked by Ivan Ivan on Aug 16, 2017
Latest reply on Aug 16, 2017 by waclawek.jan

Hello. I'm developing an application based on Discovery board with stm32f429I.

And now I have quite a weird issue: a high signal level is shown on unconnected input pins.

Here is a code:

//Configure PC4 = input
#define GPM_IN          ((uint32_t) 0x00000000) /*GPIO_Mode_IN*/
#define GPb04     8
#define GP_HiSpd     ((uint32_t) 0x00000003)/*GPIO_High_Speed*/

GPIOC->MODER=(GPM_IN<<GPb04);
GPIOC->PUPDR=( (GPIO_PUPDR_PUPDR4_1) );
//((GPIO_OTYPER_OT_4));
GPIOC->OTYPER=0;
GPIOC->OSPEEDR=(GP_HiSpd<<GPb04);     

I have tried different parameters of pullup and pulldown resistors, referring the following:

http://www.electronics-tutorials.ws/logic/pull-up-resistor.html 

microcontroller - Unused MCU pins, better to tie to GND or use software to prevent floating? - Electrical Engineering St… 

 but the issue persists, IDR4 bit shows '1' in debugger, while I'm expecting it to be 0. Strangely, but a similar configuration works OK for other ports. I have checked in debugger, nothing rewrites PC4 configuration, MODER4 is 0 as it should be. I suppose that for GPIO input I should enable pulldown resistor because it links input to Ground, which is believed to be as source of zero and use push-pull mode, because StackOverflow answer states that opendrain mode is used with pullup resistor...

How to correctly configure GPIO for input?

Outcomes