Hello,
There is an internal pull-up activated during reset and the device you have (STM32G474) and according to the reference manual RM0440 belongs to the category 3:

which doesn't feature the option byte to disable that internal pull up.

So the internal pullup is internally hardwired in your device (category 3). Not possible to deactivate it.
The 27ms duration you are seeing depends on the reset assert duration on NRST pin.
The internal pull-up resistor value is around 40K. The only thing I can suggest is to add an external pull down resistor to make a resistor divider on the GPIO output to compensate that voltage.
Meanwhile you need to make sure you calculate that resistor in a such a way the output voltage during the reset phase is lower than the VIHmin of your relay circuit activation.
Suppose the VIHmin of your circuit = 2V.
Vmax = Repd/(Ripu+Repd) * VDD < 2V
Where:
- Repd is the external pull down resistor to calculate
- Ripu is the internal pull-up = 40K
- Vmax the voltage you shouldn't exceed on PB4 to drive the relay.
If you fix Vmax at 0.5V, after calculation you find Repd = 7K.
Conclusion: with these conditions, if you put a pull down resistor of 7K on PB4, you should have maximum level of 0.5V on the output which I think acceptable.
Hope that answers your question.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
