4
\$\begingroup\$

What I am trying to do is program the ATmega328P on a breadboard. I have followed the schematic by which the Duemilanove board was wired to no avail.

I have a SparkFun AVR Pocket Programmer that works fine. I am able to successfully program, using ISP, the ATmega328P on the Arduino Duemilanove board. Further, I am able to remove the stock controller, replace it with a new controller (same model and same chip I am attempting to program on the breadboard), and program successfully as well.

enter image description here

I directly connect the following:

  • MISO to pin 18
  • SCK to pin 19
  • RESET to pin 1
    • RESET also has a pull-up resistor
  • VCC to pin 7
  • MOSI to pin 17
  • GROUND to pin 8

I have tried tying AREF to VCC and both GROUNDs together - still nothing. I also tried programming the board by powering it externally (i.e. removing VCC from the ISP connector). The pins I have described above are the only connections. Is there something I am missing here?

There error I get is:

enter image description here

Where I have read this result indicates that the programmer cannot connect to the target board.

I tried looking over the schematic further to see if there were any extra connections that I was missing(i.e. some other grounded or 5V supplied pin I would otherwise be bypassing by tying VCC directly to pin 7); I could not find anything. Any suggestions?


Here is the verbose output ( -v flag using avrdude ). I am not sure what to make of this information.

enter image description here

\$\endgroup\$
  • \$\begingroup\$ Just going from memory but doesn't the reset line normally need a pull-up resesitor? I wouldn't be suprised if the programmer only pulls it to ground to avoid voltage difference problems. \$\endgroup\$ – PeterJ Dec 20 '13 at 3:06
  • \$\begingroup\$ I should add that I also tried that. Thanks for commenting about it though; I will add this to the main post. You are right too; the RESET line on this controller is active low. \$\endgroup\$ – sherrellbc Dec 20 '13 at 3:07
  • \$\begingroup\$ I remember mine being extremely finicky as well, and if I remember correctly, suggestions made to me that a pullup resistor was needed also had no effect. Rather, I used a capacitor much like when programming an ATtiny85. Can't remember exactly though, will have to check it tomorrow. Also, this is happening to trying to burn the bootloader? Or just programming it? \$\endgroup\$ – krb686 Dec 20 '13 at 4:30
  • \$\begingroup\$ Just trying to program the board. I would very much appreciate any information that let to your solution to this problem. \$\endgroup\$ – sherrellbc Dec 20 '13 at 4:32
  • \$\begingroup\$ Could you change the screenshot to text, so other visitors may find this question when Google'ing for it? You can copy & paste text from command.exe by right clicking. \$\endgroup\$ – jippie Dec 20 '13 at 8:12
2
\$\begingroup\$

The 328P has a weak internal pullup on the reset line, but it is recommended by the vendor to add an external pull-up if connecting any external reset circuit. In my experience, the MCU also needs to be powered externally. If you have any other SPI devices on the MOSI or MISO lines then make sure they are disconnected or in tri-state mode before programming. Do not use pull ups/downs on the MOSI/MISO/SCK lines... those are driven lines. Also, please note that the MCU can only be programmed while being held in reset state. If that doesn't work, ensure that your MISO/MOSI/SCK lines are connected properly and not reversed - pretty easy to do on a breadboard. I always use real Atmel AVR ISP Mk II programmers and have no problems. The items I've listed have been the only things I've run into when programming an AVR device. Cheers!

\$\endgroup\$
  • \$\begingroup\$ I have applied an external pull-up resistor on the RESET pin. I have also checked, and rechecked, to make sure the required pins are in the correct orientation. As it stands in the circuit, there is nothing connected to the MCU aside from the control lines from the programmer. Also, what do you mean by "driven lines." Are you referring driven with respect to the programmer? \$\endgroup\$ – sherrellbc Dec 20 '13 at 3:45
  • \$\begingroup\$ Yes, with respect to the programmer. When the MCU is in reset state it can be programmed. The programmer acts as an SPI master and the MCU as the slave. By driven lines I mean that the voltage is either driven high or low by the transmitter and that pull up/down resistors are not required such as with I2C or other open collector/drain lines. My next questions are: 1) do you have an external oscillator/crystal connected? If so, you will need to change the clock source fuses. If not, the internal clock will be used. And 2) if you have not checked the fuses, I would check them out. \$\endgroup\$ – Pugz Dec 20 '13 at 4:39
  • \$\begingroup\$ Arduino requires that a certain combination of fuses be used or you have to modify files inside the Arduino core that affect how the MCU uses the clock. \$\endgroup\$ – Pugz Dec 20 '13 at 4:39
  • \$\begingroup\$ I am not using an external crystal and am also not using an Arduino bootloader. I have successfully programmed the chip by inserting it into an Arduino board (and using ISP), but am not able to implement the required connections on a breadboard necessary for programming; this is what I am trying to find out. The chip programs fine when in the Arduino board but fails when programmed is attempted otherwise. \$\endgroup\$ – sherrellbc Dec 20 '13 at 4:49
  • \$\begingroup\$ Another thought - it's possible that there is too much capacitance in the breadboard connections for the high frequency signal of the programmer to the MCU to get through properly. You can test this with an oscilliscope or solder the same circuit up on protoboard. Breadboards are known to be bad for high frequency signals but I would imagine it would be okay for programming something this slow. Either way, at this point you really need to hook up an oscilloscope to the MCU's pins and see what's going on on at minimum MISO, MOSI, and SCK. \$\endgroup\$ – Pugz Dec 20 '13 at 5:14
1
\$\begingroup\$

AVR has some nice application notes for hardware considerations. Of particular interest might be application note 042 particularly figures 2-2, 2-3 and 3-2.

Figures 2-2 and 2-3 show the recommended RESET pin schematic. There are several differences between the recommendation and your schematic: the capacitor pull-down to ground, the pullup resistor and the in-line resistor on the reset switch. Note that the RESET line from the ISP gets attached directly to the RESET pin on the uC while the external reset switch has the resistor between it and the RESET pin. I've never had any luck with that diode in the reset schematic and I'd encourage you not to bother. When I use it, the chip could be programmed, but power had to be removed and re-applied for it to work.

Figure 3-2 shows resistors between the SPI devices and the SPI pins on the uC while the ISP lines are connected directly to the SPI pins on the uC. That may be another issue.

Additionally, you can read Application Note 910 regarding in-system programming. I can't point you to anything specific, but I often find that reading those sorts of background documents when I'm banging my head against a wall gives me a brilliant insight that fixes everything. Sometimes.

Good luck!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.