cancel
Showing results for 
Search instead for 
Did you mean: 

I'm using NucleoF401RE. The issue is that GPIO Read pin is always SET. There is nothing connected to board. No pull-up resister connected. When i try to debug, HAL_GPIO_ReadPin always returns Pin_Status as SET.

Qsdxkh
Associate II

Code isn't complex, hence i don't understand what could be the problem.

char pin_status;

pin_status=HAL_GPIO_ReadPin(SENSOR_H1_GPIO_Port,SENSOR_H1_Pin);

0693W00000Y9bP7QAJ.png

3 REPLIES 3
KnarfB
Principal III

If there is nothing connected, the pin is floating and the result undetermined, maybe 1 maybe 0.

hth

KnarfB

gbm
Lead II

There is no problem. If nothing is connected and the pin is not pulled up or high internally, random level is read. Random may be 0 or 1, depending on humidity, air ionization, touching etc. Enable the pull-down to force it to 0 when left open.

S.Ma
Principal

First, read the GPIO HW registers in debug mode, not a variable .

Second, manually turn the GPIO MODER and OUT registers to turn the pin to output low.

Then check the IDR pin level.

If the registers are always zero, the GPIO clock enable is missing

If the input level does not change, the pin is forced by external HW to its level.