Hello world,
This might belong in the electronics forum, but my fundamental issue is not being able to upload a sketch via USB.
The schematic for the board in question is attached, simplified to show only the USB (and ICSP) related connectivity. It's what should be a straightforward implementation of the ATmega2560 using the FT230XS for the USB bridge.
I can upload the stk500boot_v2_mega2560.hex bootloader with an AVR-ISP-MK2 over the ICSP header and it works just fine. The output after writing and the subsequent read/check is:
avrdude: verifying ...
avrdude: 150208 bytes of flash verified
avrdude: safemode: Fuses OK (E:FF, H:99, L:62)
avrdude done. Thank you.
So that seems good.
Now looking at the USB-UART side of things, I can short the Tx and Rx UART pins for hardware loopback, and this works as well. Characters transmitted from puTTY echo back, and my little Rx and Tx LEDs light up. Good.
So now I looked more carefully at the connections between the FT230XS and the ATmega. There were a few issues that I've identified and resolved over the past couple weeks. These were:
-
Pin 4 (ID) on the USB micro-B connector was tied to ground instead of being unconnected. Resolved.
-
I didn't have 1K resistors on the Rx/Tx UART lines to the ATmega. Resolved.
-
The ATmega RESET's filtering cap to ground was going through an extra resistor. Silly mistake that should not have mattered, but resolved.
-
Here's a big one: I forgot to run the RTS output on the FT230X to the ATmega RESET via a .1uF cap. I thought for sure this would be the ultimate fix, but now this is resolved and still no luck.
But still no. If I attempt a sketch upload I get the standard "avrdude stk500v2_receivemessage() timeout".
The attached PDF is representative of the current state of the circuit.
I've checked that the ATmega's RESET pin is seeing the spike to GND when I try to upload a sketch, using an O'scope. I've also confirmed that there's activity on the ATmega's RX pin when the sketch upload is attempted. But again, hardware loopback works, so that seems solid to me.
Okay, with the above as primer, the plot will thicken:
I can upload a sketch using the ISP by clicking Sketch > Upload Using Programmer, and this works with a simple blinky test on pin 13, BUT, the blinking happens at least an order of magnitude too slow! With a 50ms delay between LED ON and LED OFF, the LED cycles just a bit faster than once per second.
So, it seems like perhaps the clock fuses are somehow not being set correctly in the bootloader, which would explain why I can upload via an ISP but UART communication between the ATmega and the FT230XS fails.
But I'm using the standard bootloader hex file so I don't see how that can be. The resonator I'm using is indeed 16MHz and there isn't a whole lot of room for messing things up with that part of the circuit, although I notice that crystals seem to be more common. My scope probes can't pick up the 16MHz clock signal so I can't do a sanity check with that without investing in a better probe.
I'm not one to post on a forum unless truly at wit's end. Any ideas from the community?
~Justine
ATMega2560+FT230XS_Minimal.pdf (53.5 KB)