2
\$\begingroup\$

How do you program the SMD ATMega328 IC in an inexpensive way?I know you can get a factory to program the chips but is there a way to program them with Arduino without one of those expensive sockets.

\$\endgroup\$
2
\$\begingroup\$

Yes, you put a 6 pin ISCP header on the PCB to support flash programming, buy a $5 USBASP programmer from Ebay, and flash the Arduino program straight to the board, skipping the whole serial/USB bootloader stuff.

I've done this for years now, it's fine. An important thing to note is to use Arduino environment (with the equivalent/reference board, processor, voltage and frequency settings correct for your target board) to flash the bootloader first. This sets all the fuses to ensure the ATMEGA uses the correct clock frequency and other fuse settings which are normally a pain to work through the datasheet/online tables.

After you burn the bootloader, then use the Arduino environment as normal, but select the "Upload with programmer" instead of "Upload" and this will use the USBASP (make sure to select the programmer in the programmer tools options) to flash the program directly to the ATMEGA, rather than the USB bootloader method.

This is great for if your boards do not have USB on them, like for very small projects where it's not needed. Debugging can still be done by using an external serial interface like a FTDI USB-Serial adapter on the ATMEGA's serial pins (which you need to break out to a header somewhere with RX, TX, and GND)

Of course, you can use the official Atmel AVRISP Mk2 or full on JTAG style interface to flash the chip. Either way, your PCB which the SMD IC is going to be soldered on to should have the support for flash programming. If not, add it. As you said, a socket to program out-of-system is not really a good solution. Large scale production runs should indeed be pre-programmed at the factory to avoid all this nonsense - but that is very far down the line for product design. At a prototype level, just put the header on for ISP programming, and serial breakout.

\$\endgroup\$
  • \$\begingroup\$ would it be possible to program the smd chip the way you program the dip version except solder the wires to the smd ic or does that not work? \$\endgroup\$ – DC1712 Apr 20 '15 at 17:55
  • \$\begingroup\$ Well the DIP version does exactly the same thing - you either have a pre-flashed serial bootloader, and use serial, or you use ISP flash programming like I described. Soldering wires to the SMD chip is a terrible idea, just put it in-circuit and do it properly. What is the chip going onto/into? Why get SMD chip if you cannot deal with it properly, but can deal with DIP chips? \$\endgroup\$ – KyranF Apr 20 '15 at 17:56
  • \$\begingroup\$ Sorry for taking your time it's just i want to get into smd chips and making circuits smaller but what pins would the iscp header be connected to? \$\endgroup\$ – DC1712 Apr 20 '15 at 17:59
  • \$\begingroup\$ Please read the datasheet for ATMEGA series chips and their programming methods. The SPI bus, plus reset VCC and GND are needed, for a total of 6 pins. \$\endgroup\$ – KyranF Apr 20 '15 at 18:00
  • 1
    \$\begingroup\$ @DC1712 "would it be possible to program the smd chip the way you program the dip version" - The integrated circuit (what's inside the black package) is the exact same for the SMD and DIP versions. The only thing that changes is the metal that connects it to the outside world. Take a look at how these DIP programmers actually work, and do that (which is what Kyran is telling you). \$\endgroup\$ – Greg d'Eon Apr 20 '15 at 18:33

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.