Skip to main content
Ala
Senior
August 7, 2022
Question

capacitor does nut fully charge

  • August 7, 2022
  • 7 replies
  • 1267 views

hi

I have a 1000uF capacitor and a blue pill STM32F103c8t6. I connected the positive end of cap to PB9 and the negative end to GND.

then I had the code below inside while(1) loop

///////////////////////////CHARGE//////////////////////////////////
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_9,GPIO_PIN_SET);
HAL_Delay(10000);//wait to fully charged

but when I measure voltage using a multimeter, I see 0.5v instead of 3.3v. why?

Edit. when I use 1uF cap or less, I see 3.3v... can someone explain that?

This topic has been closed for replies.

7 replies

Tesla DeLorean
Guru
August 7, 2022

You'd need more code than that to enable the pin

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
MasterT
Lead II
August 7, 2022

There is a risk of damaging uCPU. Look into datasheet, max. GPIO current limits section. Usually it's just 3 mA. Than put appropriate resistor in series to limit current.

Piranha
Principal III
August 7, 2022

For STM32 the absolute maximum is typically +/-25 mA.

Piranha
Principal III
August 7, 2022

Until the capacitor charges, it is basically a short circuit... You have to limit the current with a 180 ohm or higher resistor or by some other means. And learn the basics of electronics.

Ala
AlaAuthor
Senior
August 8, 2022

you're right. I forgot to say that I've used a 1Mohm resistor in parallel with the cap

Piranha
Principal III
August 9, 2022

To limit a current you have to put a resistor in series. That is the absolute basics of the electronics. While you do not understand such a things, you should not connect anything to any microcontroller or any integrated circuit at all - you will just damage it. Take a battery, LED, resistor, switch/button and learn the absolute basics. When you can calculate the correct resistor value, then you have understood the absolute minimum to go further.