Go Down

Topic: programming atmega328p-an with Usb 2 serial converter (Read 5252 times) previous topic - next topic

notfet

My eventual goal is to mount a atmega328p-an, smt microcontroller  to a board I am making but I need a way to program it. I am trying to test loading scripts so I have a boot loader pre-programmed atmega328p-pu with 5 volts and gnd. to all the approiate pins. A 16 Mhz crystal and 22mfd caps. A Usb 2 Serial converter wired in the following in the following manner reset to a .1 Mfd cap to pin1. rx to tx and tx to rx. 5 volts and gnd.  Board set to UNO, the correct serial port, But It will not load. The RX and TX lights on the converter flash briefly and then I get the following error,   avrdude: stk500_getsync(): not in sync: resp=0x30 what could be wrong?

larryd

No, 22mfd, you need 22pf

Show us a image of the circuit.
No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

notfet

#2
Apr 05, 2014, 08:22 am Last Edit: Apr 05, 2014, 08:25 am by notfet Reason: 1
Sorry I meant 22Pf Here is the circuit The led's and 470ohm resistors are to test that the script works. The Usb 2 Serial converter is Arduino part# A000059 Thanks.

Paul__B

Well, you are missing the 10k pull-up on the Reset pin.

What strikes me however, is that the pin to the USB-serial converter is labelled "Reset".

If it is indeed  labelled "Reset", then you have a "bodgie" USB-serial converter from eBay.  These counterfeits have been designed by someone who is not an electronics engineer (i.e., did not understand what he was doing) and bring out the actual "reset" pin on the CP2102 chip, rather than the RTS or DTR pin.

You will have to check the wiring on the converter board - OK, I'll look it up - "reset" is pin 9, you need to cut the track and connect the pin on the spill to pin 24 on the CP2102 instead.  I use a piece of fine "Biceflux" coil/ transformer winding wire whose enamel melts (and acts as flux) to enable it to be soldered easily, for this repair.

(Curiously, "Biceflux" seems to have disappeared and Google mostly finds my previous postings on it here and from something like 15 years ago on PIClist!)

notfet

It was factory sealed from M!@#$r electronics I cut open them myself But I do not have the pull up resistor I will add it and let you know.

notfet

With the resistor soldered to +5v to pin 1 and the rest of the circuit unchanged Now the RX light flashes twice(TX off) and I get the following error  avrdude: stk500_recv(): programmer is not responding. I can put the chip back in a UNO and it loads fine what is wrong now?

Paul__B


It was factory sealed from M!@#$r electronics I cut open them myself.


I am not sure what being "factory sealed" has to do with matters or what you mean by "cutting them open" yourself, but if the USB-serial converter has a pin labelled "Reset", it is faulty (by design) and needs to be repaired as I previously described, before it will be possible to use it to auto-reset - though if you have fitted a reset button, you can reset the chip manually, momentarily when you see the "Completed compiling" message.

If you want more accurate interpretation of the matter, you need to post a link to or proper images of the USB-serial converter in question.


I get the following error  avrdude: stk500_recv(): programmer is not responding. I can put the chip back in a UNO and it loads fine what is wrong now?


Since you are not using a "programmer", you have evidently set the wrong sort of download in the IDE options on this occasion.

notfet

#7
Apr 06, 2014, 04:30 am Last Edit: Apr 06, 2014, 04:34 am by notfet Reason: 1
Here is the info I have so far and a picture of it. No it is not a programmer it converts the USB signals into Two signals that the atmega328p can read. RX and TX. The part you are describing is incorrect. I blurred out the place I got it from because I did not want to violate any rules of advertising. But it is Mouser part# 782-A000059. Manufactured from Arduino. You can see the data sheet from there. That is the way I connected it. The only chip on the Board is Atmel mega8u2. I connected it exactly the way the data sheet describes. I will try adding a switch but if possible I would like the reset done automatically just like the UNO does.

notfet

#8
Apr 06, 2014, 06:14 am Last Edit: Apr 06, 2014, 11:26 am by notfet Reason: 1
I have amended the circuit as follows, The 10k resistor I added a switch in series with it.(So that the converter can still operate as per the initial schematic. But run Scripts. I uploaded the following simple code from a UNO then took out the chip and put it in this board so that I know that the crystal is working and the atmega328. It does but I still cannot load from this board. The UNO uses the same chip as the Usb2 serial converter the only difference is a 1k resistor in series with RX and TX. Is this my problem?  
EDIT... 1k resistor did nothing.

Paul__B

OK, I follow now that you are using the proper Arduino USB-serial converter, so that clearly is not a problem.

I cannot fathom why you would place a switch in series with the reset line pull-up resistor; there is no circumstance in which you would not want the pull-up to be effective and of course, the pullup is part of the UNO design, so it should be patently obvious that it is expected always to be there.

It really is a simple arrangement; there are very few things to go wrong.  I have checked your (second) schematic against the Pro Mini circuit to check that the Rx and Tx connections are correct and they do seem to be.  I think you need to do two things here - one is to connect a reset pushbutton correctly, that is to ground, and remove whatever other arrangements you have made with switches - the 10k pull-up should always be in place and until you have it working correctly, the reset capacitor should always be connected.  You can then verify that a manual reset will work, briefly pressed when the IDE indicates it has finished compiling.

The other check is what you have not described so far - does a sketch compiled to flash those three LEDs on the UNO in some pattern, then function correctly when that same chip is transferred from the UNO to your breadboard?

notfet

The reason the switch is in line with the resistor is purely experimental. (the Resistor must be in the circuit in order for a script to run.) With the resistor in the circuit it flashes the Rx light only twice and errors with problem uploading to the board. I can push the reset button(which is wired from pin 1 to ground)  It says compiling...then it starts writing the script. RX and TX lights are on, and the progress bar stalls at the end and I get the error in post #1. with the resistor disconnected via the switch it will write automatically but, same as above the progress bar stalls and I get the error in post#1. changing the order in which the LED's flash(like middle on then outer two on etc.) can only be written if i put the chip back in the UNO.

Paul__B


The reason the switch is in line with the resistor is purely experimental.


But unfortunately, meaningless.


the Resistor must be in the circuit in order for a script to run.


Actually, no; not as such.  The script will run without the pull-up resistor, but may exhibit erratic behaviour.  The time constant will be prolonged, so the auto-upload (or indeed, manual reset) may or may not work without it.  It's not a useful exercise by any means.


With the resistor in the circuit it flashes the Rx light only twice and errors with problem uploading to the board. I can push the reset button (which is wired from pin 1 to ground)  It says compiling...then it starts writing the script. RX and TX lights are on, and the progress bar stalls at the end and I get the error in post #1.


I am not at all sure what you are describing.  It is not particularly important when you press the reset button, but it must be released a fraction of a second after you see the status "Uploading" in the blue status bar above the black window at the bottom where information and errors appear.  It is therefore easiest to press it fairly briefly just when you see the "Uploading" signal.   (Half a second seems to work for me.)


with the resistor disconnected via the switch it will write automatically but, same as above the progress bar stalls and I get the error in post#1.


It is not obvious what you mean by "it will write"?  The error is presumably the same either way, "not in sync", so what is the difference in behaviour (though having said that, this is unlikely to be relevant)?


changing the order in which the LED's flash(like middle on then outer two on etc.) can only be written if I put the chip back in the UNO.


So you are then saying that with the sketch uploaded by putting it in the UNO, the sketch does then execute in your breadboard.  Do the LEDs flash at exactly the same rate in either board?

{Picky point - looking back at the early posts, I doubt you are using any capacitors in the mfd (milliFarad) or Mfd (MegaFarad) range.  XD}

notfet

Quote
It is not obvious what you mean by "it will write"?  The error is presumably the same either way, "not in sync", so what is the difference in behaviour (though having said that, this is unlikely to be relevant)?

You are correct the problem is not in sync. How do I get in sync.

Paul__B

It would help if you answered the questions I posed with some precision.

We need at this point to know that your Rx and Tx connections are correct - write a sketch to it on the UNO that generates continuous serial output, put the chip on your breadboard and open the serial monitor to see that you are getting that output.

If that fails, try swapping Tx and Rx.  If it succeeds, then try using manual reset as I have detailed it above.

notfet

An excellent idea. It did not work. So I got another converter and the TX. communicated with the serial monitor. and loads scripts automatically(no more switch 10k resistor in play.) now on to making a test board for the smt micro-controller. Thanks.

Go Up