I have a battery powered application and want to somehow "protect" the battery from seeing too high currents. For that I have introduced a serial resistor to limit inrush current. After a certain time the resistor gets bypassed via a Mosfet.
It has an effect on the inrush current but it's still not like I would imagine it.
When meassuring with a current probe between the Battery and my circuit I can still see a peak when switching power on as well as when I activate the Mosfet (blue line). (red line shows voltage on uC pin)
can someone explain what happens here and how to prevent those spikes?
//e: uC is a STM32 and configured as openDrain without internal PullUp/Down
//e2: after adding a N-FET to activate the P-FET as suggested it looks like this:
//e3: so the first spike is still there, even when disconnecting the uC by removing R50 as suggested by @DKNguyen
//e4: implemented @Indraneel's Solution with C2=0.1uF and R2=500k and keeping R3 at the initial 18ohm. This could be a solution. Still curious why it is not working with the uC