Which microcontroller should I use which will survive voltage spikes?
I am designing a motor controller using STM32G030c8t6. but while connecting it to battery, if positive terminal gets connected to the battery before the negative terminal, then a voltage spike (of the voltage of battery) occurs on the board and it appears on Tx pin (PB6) which is damaging the microcontroller. But due to some mechanical limitations, there is no way to ensure that the negative terminal of battery gets in contact to battery first. Is there any way to protect board from this spike electrically.
I tested this on a reference board which has another microcontroller (XCM - V NRFYT 2147), and on it the same spike appears on the microcontroller pins but the microcontroller survives. Is there any microcontroller from ST family that can survive this spike? I was not able to find any datasheet for this microcontroller, but in this link https://www.yoycart.com/Product/639443123789/, which appears to be a similar microcontroller, there was mention of some ST microcontroller such as STM32F031C6T6. So is this microcontroller similar to it? I used STM32 MCU product selector but there was no major difference between the microcontroller I use (STM32G030c8t6) and STM32F031C6T6.
