During reset, all I/O registers are set to their initial values, and the program starts execution from the reset vector
so there are a couple of changes to get the reset done properly:
This means we need to:
Zero out just the I/O registers, not all the SRAM
Make sure all the peripherals are reset (the peripherals can set the reset value of their I/O registers for those who aren't zero)
Datasheet says:
This means we need to: