This question already has an answer here:
I'm using a ATSAM4S device and I've encountered some problems. I've assembled two boards that are very similar(same pinout, same devices, just a change in LED GPIOs and MCU position on board). First one works very well, second one created me problems from start, like wrong ID, security bit set when it wasn't ecc. I've not used it for a while but now I need to use this board. Programming now working well(don't ask me how, I've switched to JTAG from SWD and this solved all problems also for switching back to SWD) but now, if I load the same code that is on the first, well working, board to this MCU, it goes random to HardFault in debug mode. Also when running simply code as LED blink, MCU resets at random after some seconds. Main cause of this problems is related to faulty MCU or PCB board(as after a lot of test I can't say that is a code error). So, since it's more probably that it's a PCB error, what can be the main problems that cause a MCU to reset randoms after some seconds?
p.s. I've tried same code on either MCU, changed to more stable power supply, tried simply codes, still have problems on this MCU.