1
\$\begingroup\$

I am currently trying to figure out a problem that I couldn’t understand the reason for.

Here is the schematic of the circuit: enter image description here

Last weekend, I soldered a PCB on a prototype board. The circuit contains a transformer and an STM32 (which is a Blue Pill) for time counting. The transformer is rated for 230/9 V at 50 Hz and has a power rating of 1.2 VA. The STM32 works great when I power it using the programming header with the ST-Link device. It also works with 230 V.

However, the problem arises when I apply 230 V to the circuit: the STM32 RTC time jumps randomly. For example, if I set the time to 10:45 and then power off the circuit, when I re-plug the circuit into the mains voltage after a while, the time jumps to something like 15:10. This behavior is completely random, and it doesn’t occur when I power on/off using the programming header with the ST-Link device. Therefore, the problem must be somewhere on the transformer side.

As you can see, the secondary side of the transformer is regulated by an LM317. The output of the regulator is around 4.1 V. There is an onboard regulator on the Blue Pill (RT9193) for 3.3 V regulation, which provides sufficient power for the STM32F103.

What do you think ? Any idea ?

\$\endgroup\$
2
  • 2
    \$\begingroup\$ "power off the circuit, when I re-plug the circuit into the mains voltage" - what is powering the system (or RTC) while it's unplugged? \$\endgroup\$ Commented Oct 22, 2024 at 8:45
  • \$\begingroup\$ @Attie No power. It is complitely power off. Only battery remains active when power of the stm32 off. "re-plug" means complite power on/off cycle \$\endgroup\$ Commented Oct 22, 2024 at 8:56

1 Answer 1

3
\$\begingroup\$

I recommend you ensure the bootup sequence of the chip is configured correctly and the RTC is only accessed or written when stable power supply is guaranteed.

For example, configure the PVD and insert additional waits in software.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ @Justme you are correct, the on board regulator should work fine \$\endgroup\$ Commented Oct 22, 2024 at 9:35
  • \$\begingroup\$ @Jeroen53, I just realized something. When I power on the STM32 using the programming header pins and then power it off, followed by powering it on again with 230V mains power, there is no change in time the first time. However, when I power it off and on again with 230V mains voltage, the time changes randomly. I think this indicates that the problem occurs during the power-off cycle of the STM32. \$\endgroup\$ Commented Oct 22, 2024 at 10:40
  • \$\begingroup\$ Can you use a scope to review the collapse of the +4.1v rail when you disconnect mains power? How fast / is it monotonic? \$\endgroup\$ Commented Oct 22, 2024 at 10:49
  • 1
    \$\begingroup\$ @Jeroen3, as you suggested, I placed a delay at the beginning of the code before the RTC_Init() function. This way, the STM32 now waits for a second after power-on. Thanks, the problem is solved! \$\endgroup\$ Commented Oct 22, 2024 at 11:25

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.