I'm having problems uploading sketches to my custom arduino uno design. I have a ttl to usb based on the ch340 and at the same time I have a RS485 transcriber both conected to the atmega328 serial port, since I know I can't use both devices at the same time I added a jumper (J11) to enable or disable the RS485 part of the circuit when I want to upload sketches or use the USB port to debug my code, following the arduino uno design I added two 1K resistor in series on the RX and TX (R29 and R30) see https://electronics.stackexchange.com/a/213167/123482 so the RS485 takes preference over the USB when selected with the jumpers.
I have tracked down the issue to my USB part of the design, if R15 and R16 are 320k like on my schematic the arduino IDE can't upload code to the board, avrdude timeouts, if I change the resistor values from 320K to 1K most of the times the upload works as expected but fails when it tries to read back the flash memory, if I remove the resistors it always work as expected. Obviously the problem is there but why?
enter image description here enter image description here
Note: Added 328 pinout
-
\$\begingroup\$ Did you use a programmer and burn the bootloader on the 328? Arduino only works because the stock 328 has a custom bootloader burned on it. \$\endgroup\$MadHatter– MadHatter2018年11月25日 21:19:48 +00:00Commented Nov 25, 2018 at 21:19
-
\$\begingroup\$ The LEDs are resistors are masking another issue by forcing the IO lines high or adding excessive loading on them. Remove R15,16 and only add them back after it is working. \$\endgroup\$MadHatter– MadHatter2018年11月25日 21:23:04 +00:00Commented Nov 25, 2018 at 21:23
-
\$\begingroup\$ Also a schematic showing the 328 pinout etc. Would be helpful... \$\endgroup\$MadHatter– MadHatter2018年11月25日 21:24:09 +00:00Commented Nov 25, 2018 at 21:24
-
1\$\begingroup\$ @MadHatter yes, I used the ISCP to burn the bootloader. Is fully functional as I can upload sketches using the USB port when R15 and R16 are removed \$\endgroup\$Marc– Marc2018年11月25日 22:47:01 +00:00Commented Nov 25, 2018 at 22:47
-
\$\begingroup\$ Measure R15/R16 with a meter, see if they are really 320K. I wouldn't expect that high of a resistance to even let the LEDs turn on. \$\endgroup\$CrossRoads– CrossRoads2018年11月26日 15:32:31 +00:00Commented Nov 26, 2018 at 15:32
1 Answer 1
Add a 10K pullup on Reset also, with a 0.1uF from DTR to Reset. That way the USB chip can cause a software created Reset to kick off the bootloader for an upload.
-
\$\begingroup\$ I already have it in another part of the schematic, anyway it's not related with the R15/R16 probem \$\endgroup\$Marc– Marc2018年11月26日 07:13:12 +00:00Commented Nov 26, 2018 at 7:13