I built a custom pcb with atmega328pb and want to upload a simple blinking sketch to it.
I have burnt bootloader with 16mhz external crystal using a Arduino Uno. However, i have this problem when trying to upload the code with a USB to TTL (FDTI module).
Avrdude version 8.0-arduino.1
Copyright see
System wide configuration file is C:\Users\DELL\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\8.0-arduino.1\etc\avrdude.conf
Using port : COM8
Using programmer : urclock
Setting baud rate : 115200
Warning: attempt 1 of 10: not in sync
Warning: attempt 2 of 10: not in sync
Warning: attempt 3 of 10: not in sync
Warning: attempt 4 of 10: not in sync
Warning: attempt 5 of 10: not in sync
Warning: attempt 6 of 10: not in sync
Warning: attempt 7 of 10: not in sync
Warning: attempt 8 of 10: not in sync
Warning: attempt 9 of 10: not in sync
Warning: attempt 10 of 10: not in sync
Warning: programmer is not responding; try -x strict and/or vary -x delay=100
Error: unable to open port COM8 for programmer urclock
Avrdude done. Thank you.
Failed uploading: uploading error: exit status 1
This is roughly the part that’s relevant. I will post the full schematic tomorrow.
I used oscilloscope to check the DTR signal, and observed that it went LOW for only 160us, then went HIGH again. I also tried to manually pull RESET pin low while uploading, but it didn’t help
This is roughly the part that’s relevant. I will post the full schematic tomorrow.
I used oscilloscope to check the DTR signal, and observed that it went LOW for only 160us, then went HIGH again. I also tried to manually pull RESET pin low while uploading, but it didn’t help
This is roughly the part that’s relevant. I will post the full schematic tomorrow.
I used oscilloscope to check the DTR signal, and observed that it went LOW for only 160us, then went HIGH again. I also tried to manually pull RESET pin low while uploading, but it didn’t help
Here are my hints and tips. Since you are not using a standard (that I know of) FTDI Basic style pinout for the programming header or have mentioned your serial adapter and how you’ve wired it, you need to check that you are connecting the TX pin of the adapter to the RX pin of the MCU, connecting the RX pin of the adapter to the TX pin of the MCU. If that crossover is not right on your new board, it will not program. I advise try setting the oscillator of the MCU to internal and bootload it; if it then uploads via serial perhaps the external clock circuit you have on the board may not be working as intended. Troubleshoot serial by using the ICSP programmer to load a sketch onto the MCU that accepts and sends some text and communicate with the MCU successfully over serial. If that works, you would know the problem is isolated to the bootloader/avrdude relationship or DTR reset circuit or perhaps fuse settings.
In my board, the UART0 is connected to the connector for communicating with USB-to-TTL adapter.
UART0 is also connected to a RS485 auto direction circuit because i want to later use Modbus. And the RS485 circuit somehow caused the problem. Below is the RS485 circuit i used, with the IC being SP485 (5V logic)
When i checked the TX, RX lines with oscilloscope, the logic level was lower than the expected 5V. Removing the SP485 solved the problem.
Well eh, i would say so yes. Since the signal from the Tx line (input to the circuit) is HIGH or LOW depending on the bit being sent (HIGH for a 0 and LOW for a 1), the SP485 will be changing from driver to receiver all the time, and depending on the state of the A & B pins will switch the RX line HIGH or LOW, which obviously interferes with any other transmission. Plus that it doesn't work as i suspect you intend it to work.
I’m not familiar with the PB variant of the 328, but if port pins PE2 or PE3 can be outputs - and since, according to your schematic, you are not using them - then use one of them to directly drive the RE & DE pins.
With your Modbus RS485, you probably have the preTransmission and postTransmission functions - depending on the library you are using. Add code to these 2 functions to control RE & DE accordingly.
and instead of branching the TX, RX traces to rs485 circuitry and the USB-to-TTL connectors, i routed them to rs485 circuit first then to USB-to-TTL, so it would be ugly to cut traces and separate them on this version..
For ATmega328PB, on your custom board if you have made available another FTDI header for the second set of RX and TX pins for UART1, you can burn the bootloader on the MCU that listens for the sketch on RX1, TX1, and just upload there. For your next PCB order you could simply use RX1 and TX1 for your RS485 stuff. If you have made available the pins necessary for ICSP programming, you can upload using a programmer or an Arduino as ISP through those pins.