跳到正文
DEV Community· Jens Schröder·· 3 天前AI 評分30

一塊無法透過 ISP 寫入程式的 Arduino Nano,以及一個串列介面看似失效的 ESP

An Arduino Nano that refused to be programmed via ISP, and an ESP with a seemingly dead serial interface

AI 導讀

Arduino Nano 的 ISP 寫入失敗、ESP32 亦無法正常透過串列介面通訊,排查後發現板上的 RST 上拉電阻為 1 kΩ,而非電路圖所示的 10 kΩ;CH340 與 ATmega328P RX 腳之間亦有 680 Ω 電阻。移除相關電阻及自動重設電容,並加裝 10 kΩ 上拉電阻後,ISP 寫入恢復正常,ESP32 的 RX 線亦可用於 3.3V 串列通訊。

正文

Jens Schröder

My attempts to flash the Nano through its ISP header kept failing. I rummaged through my drawer looking for another programmer—didn't I have a USBasp somewhere? Found at least one STK500 clone.
In the meantime, I decided to connect an ESP32 to the Nano instead, routing the ATmega328P’s TX pin through a voltage divider down to the 3.3V ESP. That should work, right? Yet nothing came back—or, if I was lucky, just garbled characters.
Cheap Chinese clones!

I even used AI to help troubleshoot.
Were my settings wrong? No.
A bad cable or swapped pins? No.

I was nearly at my wit's end. Then, I accidentally pressed the reset button at just the right moment—and suddenly, the microcontroller’s signature was read successfully!

So the wiring was fine. Was the reset circuit itself the culprit?
I took some measurements. There was no short circuit to ground on the programmer, and the reset line had continuity all the way to the Nano. What on earth was going on? Could the CH340 USB-to-serial chip be interfering with the ISP process?

I inspected the bottom of the board and noticed a small capacitor on the reset line—and right next to it, a tiny resistor marked "102“ . A 1 kΩ pull-up resistor?! I checked the official Arduino Nano schematic: it is supposed to be 10 kΩ marked "103“ ! That explained why my programmer couldn't pull the reset line low properly. I desoldered the 1 kΩ resistor along with the auto-reset capacitor.
And what about the CH340 blocking my ESP32? Looking closer at the traces, there was a 680 Ω series resistor between the CH340 and the ATmega328P’s RX pin—no wonder the weak 3.3V ESP couldn't drive the line low against a 5V CH340 through such a low resistance! So I removed that resistor too.

What about the 0 Ω resistor? That one sits on the ATmega328P’s TX line going to the CH340. Since the ATmega328P is perfectly capable of driving both the CH340’s RX input and the ESP32 (via a voltage divider) simultaneously, I left that intact.
Finally, I soldered a proper 10 kΩ 0805 pull-up resistor directly between the 5V and RST pins on top of the board—now it behaves just like the original! As a bonus, I can still use the CH340 via USB to sniff TX debug traffic while flashing reliably via ISP, and once the ESP32 is connected, the RX line is completely free for clean 3.3V serial communication.

For the serial translation from a low-voltage 3.3V TX signal to 5V, I am planning to use a 74HCT125 with a tri-state output. It is powered by 5V and interprets any voltage above 2V as a "high" signal. For the reverse direction, I intend to use two gates from a 74LVC04, powered by 3.3V; this chip can tolerate 5V at its inputs, though it performs an inversion.

來源:DEV Community · dev.to