0
\$\begingroup\$

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.

enter image description here

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.

EDIT:

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.

\$\endgroup\$
1
\$\begingroup\$

Do you mean something like this?

When "CONTROL" is driven HIGH:

DTR is HIGH, the N-FET is OFF (Vgs = 0), and RST is HIGH.

DTR is LOW, the N-FET is ON (Vgs = 5V)and pulling RST LOW.

When "CONTROL" is driven LOW:

DTR is HIGH, the N-FET is OFF (Vgs = -5V), RST is HIGH.

DRT is LOW, the N-FET is OFF (Vgs = 0V), RST is HIGH.

When "CONTROL" is in high impedance state:

R3 pulls N-FETs gate up, connecting DTR and RST when DTR goes LOW.

So basically, when CONTROL is HIGH, DTR is enabled.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
  • \$\begingroup\$ Yes, this is something very close to what I need. But the problem here is that when I have the CONTROL to HIGH and DTR HIGH, reset pulse signal goes to RESET (for example, arduino IDE sends the DTR signal to upload a sketch), but then the MCU resets and the CONTROL goes LOW, then the DTR signal can’t finish the reset pulse signal. Reset happens, but the arduino IDE fails to upload a sketch, and I believe this is because the CONTROL goes LOW during the reset. Here you can see the DTR signal during the arduino upload playground.arduino.cc/Learning/AutoResetRetrofit \$\endgroup\$ – Christos Lytras Sep 7 '16 at 8:04
  • \$\begingroup\$ are you sure CONTROL goes LOW? thats why R3 is there, to keep it pulled up when CONTROL is in high-impedance state. You can try even lower values for a stronger pullup, maybe up to ~2k, then you'll have to start making R2 smaller as well. \$\endgroup\$ – Wesley Lee Sep 7 '16 at 19:14
  • \$\begingroup\$ I didn't have much time to implement your circuit. The voltages come from my measurements and all this behavior is without any circuit. I'll give it a try today. What kind of N-FET do you suggest? A BF245C, BF256, BST82, IRF3707? \$\endgroup\$ – Christos Lytras Sep 9 '16 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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