MCUdude / MiniCore

Arduino hardware package for ATmega8, ATmega48, ATmega88, ATmega168, ATmega328 and ATmega328PB
Other
1k stars 245 forks source link

328PB Auto-reset problems #318

Closed j-malgeri closed 1 month ago

j-malgeri commented 1 month ago

Hi, I have a custom PCB with a 328PB and I'm having issues with the auto reset circuit. My problems are pretty much the same as issue #308. I can upload the bootloader without problems, but I can't do serial programming without pressing the reset button. If I press the reset button during upload, it works perfectly every time, but auto-reset almost never works.

I've tried with FT232 and CP2102, the CP2102 sometimes is able to trigger auto-reset but doesn't the majority of the time. Both programmers have both DTR and RTS pins but the results are the same with either.

Here is my schematic: help Everything is shown except a shift register connected to pins PC2-PC5.

I used the documentation provided here as reference. It seems that issue #308 was solved by adding the protection diode, but I have this in my circuit and am still having the same problems. For C2 I've tried 100nf, 147nf, 200nf, and 300nf, but it didn't seem to make much of a difference.

I asked for help elsewhere and it was recommended to me to try putting a second 10k resistor on the other side of C2, between RST_IN and +5V, in order to make sure the capacitor generates the reset pulse. When I did this it made the auto-reset work almost every time, but it does still fail sometimes. I'm sort of hesitant to accept it as a solution because I haven't seen a resistor there in any other auto-reset circuit online. What could be different about mine that I require that? I think there's probably something else that's causing the issue in the first place, but I can't figure out what it could be.

MCUdude commented 1 month ago

Are you sure that your serial adapter operates at 5v? The 328PB is very picky about the reset voltage thresholds. If the DTR/RTS signal is 3.3v out from the serial adapter, it may not trigger a hardware reset.

j-malgeri commented 1 month ago

I assumed the reset signal would be 5V, but I checked the datasheet and it says “3.3V and 5V compatible” so I guess it’s 3.3V. Is there anything I can do to my circuit to make it reliably auto-reset with both 3.3V and 5V reset signals? Thank you for your help

MCUdude commented 1 month ago

Try to replace the 100n capacitor (C2) with a 0R resistor. IIRC Avrdude 7.2 is able to drive the reset pin directly

j-malgeri commented 1 month ago

Yes, that seems to work! Thank you so much for your help

Would I be correct in assuming the diode is not needed anymore in this configuration, since the capacitor was the reason for it being there?

MCUdude commented 1 month ago

The diode is needed to prevent voltage doubling when toggling the DTR/RTS line though the capacitor. So if you remove the capacitor, the diode isn't needed. However, if a high voltage pulse (> Vcc*2) occurs on the reset pin, the chip might enter high-voltage parallel programming mode. Usually, this is not something you'd want. So keeping the diode in its place won't hurt. You can read more about HVPP in the 328PB datasheet.

j-malgeri commented 1 month ago

Yeah I’ve read about HVPP and it being unintentionally caused by the capacitor sometimes, but I guess I assumed it probably wouldn’t happen without the capacitor. Even then I suppose it would be better to keep the diode just in case. Thank you again!