I'm programming an ATmega32 chip, and have set some bits as 1 in some DDRs and PORTs. In case I forget what bits I had set to 1, is there a way to set all the register bits to a value(1 or 0) that was present in the registers when I had bought the chip. I mean I want to do a factory reset of the micro-controller. Is it possible to do it in program or AVRDUDE with USBasp or any other means that doesn't require me to buy additional hardware?

  • \$\begingroup\$ You may not be able to remove the bootloader built in . You can just reset it and reprogram the pins by doing a user created boot loader. That may be enough. \$\endgroup\$
    – Amit M
    Commented Nov 14, 2022 at 18:29
  • 4
    \$\begingroup\$ Every time the microcontroller gets reset, the PORT and DDR configuration registers also get reset to their default values. Unless you're talking about the fuses, there's nothing special you need to do. \$\endgroup\$
    – John M
    Commented Nov 14, 2022 at 18:46
  • \$\begingroup\$ @AmitM It is possible to reprogram (or erase) the bootloader with a separate programmer. I believe USBasp can do it too \$\endgroup\$
    – Eugene Sh.
    Commented Nov 14, 2022 at 19:33
  • 1
    \$\begingroup\$ To be clear, a consumer device when "factory defaulted" reloads some baseline configuration. A chip that is "erased" is totally blank however. If you're changing the code to change bits, just keep an initial copy of the code, and write that to "factory default" it. \$\endgroup\$
    – rdtsc
    Commented Nov 14, 2022 at 19:48
  • \$\begingroup\$ @rdtsc, not sure 'baseline configuration' is being clear if you're a newcomer to all this... :-) \$\endgroup\$
    – TonyM
    Commented Nov 14, 2022 at 19:53

2 Answers 2


The data sheet shows for each register its initial value. A power cycle is enough to reset all concerned registers to these values. Note that a valid pulse at the reset pin or a watchdog reset do the same, for more possibilities see the data sheet.

The values you write into registers like DDRx and PORTx are as volatile as values stored in any RAM cell. Simply write the initial values into the registers, as you like.

You cannot forget what you stored there, because you can read these registers. And since you are the developer of your program, you should know what you wrote into them.


You don't need to do anything. You don't need to do a factory reset for getting default register values.

You seem to think that somehow the MCU remembers what is written to registers like PORTD or DDRD and writes are stored permanently.

They are not. The register values are not retained between resets and powerdowns.

Just write a new program and write it to flash for running it.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.