2
\$\begingroup\$

I am planning to buy an ATmega328 chip from Atmel, place it in my Arduino board, program it, detach it later, then solder onto a PCB.

Can I just buy the chip and program it on the Arduino board, or does it need to have an Arduino bootloader?

\$\endgroup\$
5
  • \$\begingroup\$ You can use your existing Arduino board as an ISP adapter to program a bootloader and/or application program into your new chip after placing it on your board. \$\endgroup\$ Aug 8, 2014 at 0:18
  • 2
    \$\begingroup\$ @user3731004 - what is an "Atmel385"? Atmel don't recognise it, nor do they recognise atmega385, or attiny385. Do you mean Atmega328? \$\endgroup\$
    – gbulmer
    Aug 8, 2014 at 0:53
  • \$\begingroup\$ @user3731004 - will the chip 'look like an Arduino' in the target PCB ("then solder onto a PCB")? I.e. would it be able to reprogram itself over serial I/O after it has been soldered into the target PCB? \$\endgroup\$
    – gbulmer
    Aug 8, 2014 at 1:05
  • \$\begingroup\$ If you program (or buy it with) an arduino style bootloader, yes. Otherwise, no. \$\endgroup\$ Aug 8, 2014 at 3:48
  • \$\begingroup\$ @gbulmer, yes I meant an Atmel328, my apologies \$\endgroup\$
    – IronApe
    Aug 8, 2014 at 12:58

2 Answers 2

4
\$\begingroup\$

No, you can't "... just buy the chip and program it on the Arduino board"

Unless you buy a pre-programmed ATmega328, you will need an In-Circuit Serial Programmer.

Atmel sell the AVRISP mkII. Just for guidance, you might pay over 30 GBP for one of those.

There are lower-cost option based on the Open Source USBtiny

It has been improved and turned into a kit by Ladyada

A friend bought one from a well-known marketplace web site, and it works fine. I just did a quick check and found it ready made for under £5 without the plastic case. YMMV

There is also a Ladyada DIY-shield project to turn the Arduino into a programmer

There are several projects which are even simpler, e.g. Mega-ISP using breadboard as the socket to hold the unprogrammed ATmega

I would recommend you either

  1. put a 2x3pin ISP header onto your new PCB, connect it to the chip correctly, so that it can be used to program the chip when its on-board; this implies RESET and SPI can be used without causing the embedded system to break or misbehave, or
  2. don't solder the chip into the board, but use a socket instead, so that you can extract it

Then it will be straightforward to reprogram the chip if you find a bug in the code, or need to make a change; both are very common. Otherwise it will be hard to fix it.

Summary
If you already have an Arduino and breadboard, then you have everything you need to program an ATmega. You don't need to buy an In-Circuit Serial Programmer (ISP), and you will not put the unprogrammed ATmega into the Arduino. However, if you are going to do this a lot, an ISP is a reasonable investment.

\$\endgroup\$
3
\$\begingroup\$

Yes.

That is, it is possible to program it without the Arduino bootloader, but not through the serial port. Without the bootloader you must use ISP to upload code and data into the flash and EEPROM; once the bootloader is in place it is possible to use the serial connection instead.

Note that fuses and lock bits cannot be programmed through the serial port but only through ISP, so you'll probably want to invest in a ISP programmer regardless.

\$\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.