Skip to main content
cjaya.2
Associate III
Apr 28, 2023 9:21 AM UTC
Question

I am turning on/off a LED using HAL_GPIO_WritePin() but still one of the LED showing dim even though its being RESET. any idea?

..

This topic has been closed for replies.

6 replies

Peter BENSCH
ST Technical Moderator
Apr 28, 2023 9:35 AM UTC

Then a small current flows, which may well cause the LED to glow. Unfortunately, you have not included any initialisation code, but I suspect that one of the internal pull resistors is switched on or that current is flowing externally. What does your hardware look like around the LED?

Regards

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
cjaya.2
cjaya.2Author
Associate III
Apr 28, 2023 10:17 AM UTC
 GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15
 |GPIO_PIN_4|GPIO_PIN_8|GPIO_PIN_9;
 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
 GPIO_InitStruct.Pull = GPIO_NOPULL;
 GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

The GPIO_PIN_15 connected to the LED is showing dim light on even though is reset.

Peter BENSCH
ST Technical Moderator
Apr 28, 2023 10:52 AM UTC

And what about the hardware, i.e. the schematics around the LED?

How is it connected to the voltage?

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Senior III
Apr 28, 2023 11:26 AM UTC

You have NOPULL - It means can pick up noise. Try set GPIO_PULLDOWN for GPIO_InitStruct.Pull

Dudo
Bob S
Super User
Apr 28, 2023 2:25 PM UTC

WHAT??????? That is nonsense. The pin is defined as out push-pull output. It will drive high or drive low. Enabling the internal pull up or pull down will only draw more current.

Senior III
Apr 28, 2023 2:29 PM UTC

You right . I mistake with open drain. Soooorrrry :)​

Dudo