I’m building a project using an ATMega328, and for the serial communication and programming it, I’ve connected a USB CP2102 controller. The problem with atmega328 (and all arduino boards) is that the MCU resets whenever the system sends signals to the DTR pin of the serial port, for example when we have the device always connected to the USB port of a PC and the computer restarts or powers on, the MCU resets itself. To avoid this behavior, I have a physical switch which opens and closes the DTR connection from the USB module to the MCU reset pin, which works quite well.
My question is, how can I get rid of the physical switch and have the functionality to enable/disable the DTR to reset connection by software using an MCU pin?
I tried by using a NAND gate with 2 NPN transistors with inputs the DTR and a digital pin and output to reset pin, but it didn’t work well.
I am aware of altering the USB port driver files and disabling the DTR, and the RSTDISBL fuse flag, which both are not what I’m looking for. I need a simple way to enable/disable the DTR/reset connection by software and a MCU pin.