Skip to content

Commit d6af1e4

Browse files
authored
Update Arduino-usbserial.c
Fix the unusable programming port by making the erase time longer (250ms->500ms). According to the datasheet, the recommended erase time is greater than 220ms. In most cases the original program should be OK. However, in my case, the uploading is almost 90% fail rate (Device not found at comx port...). But I can manually press the erase button before the uploading, and it works well. After the proposed changes, the programming port works as expected and I no longer necessary to hit the erase button.
1 parent 790ff2c commit d6af1e4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

firmwares/atmega16u2/arduino-usbserial/Arduino-usbserial.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ int main(void)
161161
{
162162
// SAM3X RESET/ERASE Sequence
163163
// --------------------------
164-
// Between 60 and 120: do erase
165-
if (ResetTimer >= 60 && ResetTimer <= 120) {
164+
// Between 60 and 120: do erase, 60 count = 250ms
165+
if (ResetTimer >= 60 && ResetTimer <= 180) {
166166
setErasePin(true);
167167
} else {
168168
setErasePin(false);
@@ -300,7 +300,7 @@ void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const C
300300

301301
if (Selected1200BPS) {
302302
/* Start Erase / Reset procedure when receiving the magic "1200" baudrate */
303-
ResetTimer = 120;
303+
ResetTimer = 180;
304304
} else if (!PreviousDTRState && CurrentDTRState) {
305305
/* Reset on rising edge of DTR */
306306
ResetTimer = 50;

0 commit comments

Comments
 (0)