Hello everyone,
this is my first post on this forum
I'm trying to upload a sketch using arduino IDE to my custom built PCB (with ATMEGA328P).
Here's the error:
System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"
Using Port : COM4
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x53
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x53
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x53
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x53
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x53
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x53
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x53
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x53
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x53
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x53
avrdude done. Thank you.
And some considerations:
FTDI module is seen by Arduino IDE (COM4)
My device resets when I begin to upload the sketch (so reset works)
I can upload sketches and bootloader via ICSP but not via microUSB (FTDI)
Microcontroller has been already been flashed (via ICSP). It works perfectly
Serial terminal works. I've tried to receive some data from a sketch uploaded via ICSP
I think that the Wifi Module (ESP8266-12) on the PCB could cause troubles in the upload phase. What do you think about? Is it wired correctly?
Here's the partial schematics (I've deleted useless things):
USB-to-serial logic level is 5V but you are connecting it to ATmega328P and wifi chips which have VCC at 3V3 and therefore they expect logic levels at 3V3.
As you suspected, the wifi and serial USB interfere with each other. You may be able to get away with it if you put separate set of 1K resistors between USB-to-serial and ATmega328P, and between wifi chip and ATmega328P. As it is now, you have contention between USB-to-serial and wifi chips. When USB-to-serial chip tries to bring TX low, wifi chip is holding that line high. Those 2 chips are going to burn each other out, if they haven't already.
The image is useless... (so small...) So I go by your words. Yes, the ESP module can be the problem. First of all it expects 3,3V max. So be sure the ATmega on board and the FTDI are both outputting 3,3V!
Second, the ESP can pull the RX of the ATmega high or low because it's just doing it's job. I would just use a resistor between ATmega RX and the ESP TX (and a voltage divider for the other way!) and connect the FTDI's TX directly to the ATmega RX. This way if the TX of the ESP tries to pull the line high or low the FTDI can just override that (creating just a voltage across the resistor).
septillion:
The image is useless... (so small...) So I go by your words. Yes, the ESP module can be the problem. First of all it expects 3,3V max. So be sure the ATmega on board and the FTDI are both outputting 3,3V!
Second, the ESP can pull the RX of the ATmega high or low because it's just doing it's job. I would just use a resistor between ATmega RX and the ESP TX (and a voltage divider for the other way!) and connect the FTDI's TX directly to the ATmega RX. This way if the TX of the ESP tries to pull the line high or low the FTDI can just override that (creating just a voltage across the resistor).
Yes, I'm powering the ESP module with 3.3V.
So I have to just add a 1K resistor between ATMEGA328P RX and ESP TX. Nothing else?
Check out the attached picture. If you have the TX pin of the wifi and USB-to-serial chips connected together, and then going through a resistor to the ATmega328P, you need to think about what those chips are doing. What is the serial protocol doing? The TX line is held high (at 3V3 hopefully) by both the wifi and USB-to-serial chips. As soon as one of those 2 chips starts transmitting, it attempts to bring the line low in pulses. But the other chip is still holding it high. That is contention. A lot of current will flow between the TX pins of the wifi and USB-to-serial chips during this contention. They will burn each other out.
It would be better to isolate them from each other, so no pin of one chip is attached directly to another without going through a resistor. You might be able to get away with it, you would have to try it out to see. I have used a Bluetooth transceiver with my Uno before, with resistors connected as in the better diagram. It worked fine.
The best thing to do is install jumper pins, and add a jumper to connect the wifi chip only, or to connect the USB-to-serial chip only (during programming).
Separate topic: You need to study the FTDI device data sheet and figure out how to properly wire it so it does not send high logic level which exceeds VCC of the devices it is sending to. Google "Why is it important not to exceed Vcc at the input to a logic gate"
dmjlambert:
Check out the attached picture. If you have the TX pin of the wifi and USB-to-serial chips connected together, and then going through a resistor to the ATmega328P, you need to think about what those chips are doing. What is the serial protocol doing? The TX line is held high (at 3V3 hopefully) by both the wifi and USB-to-serial chips. As soon as one of those 2 chips starts transmitting, it attempts to bring the line low in pulses. But the other chip is still holding it high. That is contention. A lot of current will flow between the TX pins of the wifi and USB-to-serial chips during this contention. They will burn each other out.
It would be better to isolate them from each other, so no pin of one chip is attached directly to another without going through a resistor. You might be able to get away with it, you would have to try it out to see. I have used a Bluetooth transceiver with my Uno before, with resistors connected as in the better diagram. It worked fine.
The best thing to do is install jumper pins, and add a jumper to connect the wifi chip only, or to connect the USB-to-serial chip only (during programming).
Separate topic: You need to study the FTDI device data sheet and figure out how to properly wire it so it does not send high logic level which exceeds VCC of the devices it is sending to. Google "Why is it important not to exceed Vcc at the input to a logic gate"
Thanks. It's now clear.
I think I'll add a 2 level switch to select between Wifi Module or "Programming mode" (FTDI).
While you are not uploading, measure with a volt meter from the ATmega328P RX pin to ground. Measure from ATmega328P VCC pin to ground. Does the voltage at RX exceed the voltage at VCC?
If the last way you uploaded a sketch to the ATmega328P was via ISP, that means you don't have a bootloader on it. You need to burn the bootloader to it with ISP.
While you are not uploading, measure with a volt meter from the ATmega328P RX pin to ground. Measure from ATmega328P VCC pin to ground. Does the voltage at RX exceed the voltage at VCC?
If the last way you uploaded a sketch to the ATmega328P was via ISP, that means you don't have a bootloader on it. You need to burn the bootloader to it with ISP.
THANK YOU
I've reflashed bootloader and it worked instantly!
Right-click and select "view image". The forum software constrains it, but the actual image is just fine.
I have a number (I was gong to say "a whole pile", but it isn't quite that) of ESP8266 modules here from eBay to get working with and a Nodemcu board. Apart from the latter device, what has me spooked is the level conversion. I think I will start with a USB-TTL board set for 3.3V.
The specs suggest a CP2102 is better suited to handle (the working current of) an ESP8266 than a CH340 - which is in any case why the Nodemcu includes the SPX3819 regulator.
While you are not uploading, measure with a volt meter from the ATmega328P RX pin to ground. Measure from ATmega328P VCC pin to ground. Does the voltage at RX exceed the voltage at VCC?
If the last way you uploaded a sketch to the ATmega328P was via ISP, that means you don't have a bootloader on it. You need to burn the bootloader to it with ISP.
THANK YOU! I spent 5 hours trying to solve the exact same problem. FTDI chip was recognized, serial in both ways worked, burning bootloader worked etc etc. I forgot uploading over isp clears the bootloader