Arduino nano locking!

Good afternoon, I'm facing a strange problem with the arduino nano.

I have an arduino nano, connected by SPI with a module MAX31865 (reader of PT100) and connected by I2C with an oled display.

Everything is mounted on an appropriate pcb, and I also use timer1 to generate a 10-bit PWM signal on pin 9.

It happens that when feeding with a 24VDC source, (I have a 7812 in the input before the Arduino Vin) it turns on normally, after some on and off, it hangs, and does nothing else.

The only way to make it work again is to upload the firmware. after charging the firmware, it returns to normal operation until I turn it on and off a few times and it hangs again.

Has anyone ever come across this?

Thank you very much in advance.

the way your dropping 24Vdc down to 5Vdc for arduino is not a good idea, you have lm 7812 on the outside, and another linear regulator soldered on the inside on board of nano, 2 of them, dropping a total of ~20Vdc wasted as heat ,

use buck converter rated 5V output and feed it to nano via a 5V out pin, yes, a 5V out pin!

Additionally a regulator needs filtering with capacitors and it is always better to use a lower voltage than the RATED one as KASSIMSAMJI says.

KASSIMSAMJI:
the way your dropping 24Vdc down to 5Vdc for arduino is not a good idea, you have lm 7812 on the outside, and another linear regulator soldered on the inside on board of nano, 2 of them, dropping a total of ~20Vdc wasted as heat ,

use buck converter rated 5V output and feed it to nano via a 5V out pin, yes, a 5V out pin!

The whole system will have to be powered by 24VDC sources as it is standard from the installation site.

So I'll have to continue with the 24VDC source, the output of the 7812 is in the Arduino Vin.

The two peripheral MAX31865 and OLED Display are connected in the 5V of the Arduino.

I realize that when I turn off the power supply the LED power of the Arduino goes off, so if it is too weak to turn the power on, then it hangs.

If I wait to darken all the led power, then turn it on normally.

If it turns off and on very fast to the point where the led does not change brightness intensity, nothing happens and everything continues to work.

What the others are saying is to use a buck converter such as

https://smile.amazon.com/Voltage-Dual-USB-Charger-Converter/dp/B01IY4QFXE/ref=sr_1_1_sspa?ie=UTF8&qid=1533231903&sr=8-1-spons&keywords=buck+converter+5v&psc=1

to take the 24 volts and create a 5volt 'rail' that can power the Nano via its 5volt pin and also power the 5volt peripherals and displays.
Since it includes capacitors for filtering and a higher current capacity than going through the Nano's voltage regulator, this may solve the problems.

I have had NANO’s hang when a spike above 5 v has reached an input .
I would agree about the regulator - I’ve run NANO’s off 12v without a problem , but not with any other load connected to it , as others have said that could be the issue.

Chinese NANO’s have also failed in my hands or hung due to the CH340 chip locking up -they are not the most reliable. On some projects I’ve cut that chip out .