Uploading code via USB-Serial Adapter

Just want to hang out with other Makers and chat about stuff? This is the place to do it.
Post Reply
preetamvp
Posts: 8
Joined: Sat Sep 28, 2013 7:16 am

Uploading code via USB-Serial Adapter

Post by preetamvp » Sat Sep 28, 2013 7:38 am

Hi,

I am using Arduino IDE on Mac to upload code to a ATmega328P MCU with Arduino Uno bootloader (http://www.freetronics.com/products/atm ... kZtdWSMGGp) using a USB-Serial Adapter (http://www.freetronics.com/products/usb ... kZy82SMGGo) by following the steps listed in the link (http://www.freetronics.com/pages/tutori ... kZ5gmSMGGo).

But when I try to upload the code via the IDE I get the following error.

avrdude: stk500_recv(): programmer is not responding.

Also when I try from my windows 8 laptop (with the unsigned driver installed for the USB-serial adapter) I get a different error.
avrdude: stk500_getsync(): not in sync: resp=0x00

Not sure what these errors are or how to fix them.. :?:

Following are the components / connections used (let me know if I am missing something):
* 2 x 22 pico Farad Capacitors - between crystal and X1 and X2 pins on MCU
* 16 Mhz crystal
* 0.1 micro farad capacitor from CTS pin on the adapter to RST pin on the MCU
* Tx on adapter to Tx pin
* Rx on adapter to Rx pin
* Vout adapter to Vcc on MCU
* GND on adapter to GND on MCU
* Nothing connected to AVCC and GND pin on the other side of the MCU
* Not sure what the nc pin on the adapter is for?


Cheers,
Preetam

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: Uploading code via USB-Serial Adapter

Post by angusgr » Sun Sep 29, 2013 10:11 pm

Hi Preetam,
preetamvp wrote: * Tx on adapter to Tx pin
* Rx on adapter to Rx pin
TX (Transmit) and RX (Receive) are both labelled from the point of view of the device they're part of, so TX on one side has to connect to RX on the other side (Transmitting from one device and Receiving on the other.) Same for the second TX/RX pair.

So if you swap these two then it should come good. :)
preetamvp wrote: * Not sure what the nc pin on the adapter is for?
NC stands for No Connection.

Why would we put a No Connection pin on something we designed ourselves? The pinout of the USB Serial device is designed to be compatible with a common six pin FTDI USB to Serial cable pinout. On the FTDI cable this pin would be "RTS", used for hardware flow control, but we haven't implemented hardware flow control as it's not really needed these days.

Hope that's enough info to get you up and running.

Regards,

Angus

preetamvp
Posts: 8
Joined: Sat Sep 28, 2013 7:16 am

Re: Uploading code via USB-Serial Adapter

Post by preetamvp » Mon Sep 30, 2013 1:15 pm

Hi Angus,

:oops: Rookie mistake.. Tx to Rx makes sense.. Thanks for that.. will give it another go on the weekend and update this topic if I have still have issues.

Just one quick question.. do I need the 16 Mhz crystal connecting to X1 and X2 pin? As on Arduino Uno I see only one 16 Mhz crystal.. and the USB-Serial Adapter already has a 16 Mhz crystal.

Cheers,
Preetam

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: Uploading code via USB-Serial Adapter

Post by angusgr » Mon Sep 30, 2013 10:45 pm

Hi Preetam,

Glad you got it working.
preetamvp wrote: Just one quick question.. do I need the 16 Mhz crystal connecting to X1 and X2 pin? As on Arduino Uno I see only one 16 Mhz crystal.. and the USB-Serial Adapter already has a 16 Mhz crystal.
Yes. The crystal is used by the Microcontroller (Atmega328p) to regulate its clock speed, and without it in place it won't start running.

The one on the USB-Serial adapter is used by the microcontroller onboard there (an Atmega16u2), which runs a simple "USB to Serial" program, but it's unable to be shared by both microcontrollers.

As an aside, it is possible to run an AVR like the Atmega328p without the external crystal if you have an external ISP programmer (like the Freetronics USBAsp) to update its internal configuration settings (called "fuse bits".) However this speed limits you to 8MHz, rather than 16MHz.

- Angus

LukeW
Posts: 91
Joined: Tue Nov 01, 2011 10:14 am

Re: Uploading code via USB-Serial Adapter

Post by LukeW » Thu Feb 27, 2014 5:16 pm

2 x 22 pico Farad Capacitors - between crystal and X1 and X2 pins on MCU
It's not clear from the way you've worded it - but just checking. The crystal should be connected directly to the X1 and X2 pins and the capacitors should be connected from those pins to ground. The capacitors should not be "between" the crystal and the microcontroller in the sense of being in series.
* Vout adapter to Vcc on MCU
* GND on adapter to GND on MCU
* Nothing connected to AVCC and GND pin on the other side of the MCU
Personally, I would connect both ground pins. The chip might work successfully without both connected, but it might behave erratically. Similarly, I would connect the AVCC pin to +5V, don't leave it unconnected. The digital side of the chip might work successfully without it connected, and you might only lose functionality in the ADC side of the chip, but it might be unpredictable.

Basically, as a short guideline for quality, good engineering practice I would say that all grounds and power pins on chips should always all be connected even if they appear to be redundant and even if you're just tying them together externally and powering them from a single point.

Personally, I'd also recommend putting an 0.1uF cap across Vcc and ground directly next to the chip too... just because it's good practice, even though it will probably work without it.

Also, you may need a pull-up resistor (say 10k) on the reset line.

Basically, if you follow everything here faithfully it should work well.

http://www.freetronics.com/pages/tutori ... w9kefSSxgJ

But you can supply 5V power from the USBSerial board, and you can omit the 7805 regulator and the two larger electrolytic caps on the breadboard. I would keep all the rest of the components included as described, though.

Post Reply