Help burning and programming standalone Atmega328(P)-AU

Hi ! I'm working on a DIY Weller RT soldering station project, based on the work done by Matthias Wagner :

His original design uses an Arduino Pro Mini (5V, 16MHz), which features an [u]Atmega328-AU[/u]. I'm working on implementing the project on a single PCB with the same chip (the TQFP package) which I will solder myself (I'm essentially getting rid of the Arduino board).

Therefore, I'm trying to figure out how to burn a bootloader and program the chip. If I'm right the bootloader can be burned through ICSP with an Arduino UNO (which I own) and then the chip can be programmed through FTDI like the Arduino Pro Mini.

Now I have questions. I know they have been discussed before on this very forum and elsewhere, but it seems that there is no definitive answer...

  • The program has been written for an [u]Atmega328-AU[/u], I'm wondering if I could use an [u]Atmega328*P*-AU[/u] instead, which has lower power consumption (again, correct me if I'm wrong here).

  • The [u]Atmega328-AU[/u] and [u]Atmega328*P-AU[/u] have two extra ADC pins compared to the **DIP-packaged versions. When burning the bootloader on the chip, what board should I choose in the Arduino IDE board list for the [u]Atmega328-AU[/u] and the [u]Atmega328P-AU[/u] respectively, to make sure that the 2 extra ADC pins become functional ? As an example if I burn the UNO ([u]Atmega328P-PU[/u] **DIP* which doesn't have the extra ADC pins) bootloader in an [u]Atmega328*P-AU/u, will the Arduino IDE allow me to use the two extra ADC pins offered by the **TQFP* version ?

  • Do I really have to burn the bootloader through ICSP and then send my program to the chip through FTDI ? Is there a cheap solution requiring less pins ? Because when designing my PCB, I would like to avoid having to place 6 pads for ICSP and another 6 pads for FTDI, my PCB would get a little bit messier and I'd rather avoid having to route an extra 12 traces...

I will really appreciate any help you can provide :)

You can add your board to boards.txt. The Mini should be a good example.

For programming, all required pins should be reachable from outside, the connectors can be replaced by adapters.

You can always program your board through ICSP, without ftdi. I don't know how much extra cost a 6-pin header is. Why not adding the pin holes and decide whether to solder the headers when assembling?

Choose arduino nano when burning the bootloader or compiling sketch you will be able to use all 8 analog inputs. If you end up putting bootloader on it, the bootloader is 2KB in size, instead of 512B for UNO running optiboot loader on 328P-PU. Mini's spec is worth. 4KB is reserved for bootloader IIRC.

328P-PU and 328P-AU are the same die inside different physical package. Provide access to the SPI pins (SCK, MISO, MOS, Reset, Power, Gnd) and the serial port (Rx, Tx, DTR (go thru 0.1uF cap to Reset with 10K pullup on Reset), Power, Gnd, and Bootload/Download just the like whatever bootloader you put on the part. Make sure any devices you connect to those pins is either an Input pin, or an Output pin that is disabled when Reset is low. If you don't make the SPI pins accessible, you can use a Press-On programming adapter like this to bootload the part http://www.hobbyking.com/hobbyking/store/__64417__Atmel_Atmega_Socket_Firmware_Flashing_Tool_AR_Warehouse_.html?strSearch=atmega |500x366

328-AU vs 328P-AU are interchangeable. P is for picopower and has a couple options for brownout level that non-P does not. Different signature bytes - if you use '328P you can program like Nano, Uno, Promini, etc without hassle.

OP,

If you treat the AU as UNO, it would be able to load sketch at the highest speed, 115200, and the bootloader takes the least memory, 512B. I thought you were remaking that weller controller board. Why do you need all those analog pins anyway?

CR,

How sturdy is that adapter? I was gonna buy one but the reviews say they aren’t well built.

Thanks a lot for all those answers... Now I have a few more questions ! ;)

DrDiettrich: You can add your board to boards.txt. The Mini should be a good example.

I've heard of the boards.txt file, but what do you mean when you say that the Mini should be a good example ? Does this mean that if I choose the Mini Pro in the bootloader boards list, it will be the appropriate bootloader for a standalone Atmega328-AU (TQFP non Picopower version) ?

liudr: You can always program your board through ICSP, without ftdi.

Do I need a specific tool to do so or is it possible to do with an UNO ?

liudr: I don't know how much extra cost a 6-pin header is. Why not adding the pin holes and decide whether to solder the headers when assembling?

It's not really about cost here as I'll be making only one board. I would prefer to keep my pcb as clean and simple as possible, so that's why I was wondering if I could get rid of the FTDI pins for programming.

liudr: Choose arduino nano when burning the bootloader or compiling sketch you will be able to use all 8 analog inputs. [...] Mini's spec is worth.

What's the difference between choosing nano or mini in the IDE menu, as they both use Atmega328-AU ? What do you mean by Mini's spec is worth ?

CrossRoads: If you don't make the SPI pins accessible, you can use a Press-On programming adapter like this to bootload the part http://www.hobbyking.com/hobbyking/store/__64417__Atmel_Atmega_Socket_Firmware_Flashing_Tool_AR_Warehouse_.html?strSearch=atmega

Thanks for the tool suggestion, I'll definitely look at this solution !

CrossRoads: if you use '328P you can program like Nano, Uno, Promini, etc without hassle.

Are you sure ? 'Cause the Pro Mini and the Nano seem to use the 328, and the UNO uses the 328P. I've read on different forums that some people have trouble burning the bootloader on a chip if it's a 328 and they burn a 328P bootloader (UNO bootloader as an example) or if it's a 328P and they burn a 328 bootloader...

liudr: I thought you were remaking that weller controller board. Why do you need all those analog pins anyway?

Actually I don't need all those pins, but I wanted to know anyway as they might come in handy in a future project !

The boards.txt specifies e.g. the controller and frequency of a board. When you copy the Mini section and rename it to some new name, you have sample values for both 8 and 16MHz clock. The Mini has the same chip family and package, and consequently also has the additional analog pins declared. The fuses may be different, though.

@liudr, I've had the adapter a while and it's holding up fine. I once bootloaded up 20 boards with no issue.

" 'Cause the Pro Mini and the Nano seem to use the 328, and the UNO uses the 328P" Real Arduino's use 328P for all of those, and not 328.

Read boards.txt to answer your questions. On a board level, mini lacks USB/TTL and nano has it. On a chip level, they use the same 328P-AU. On a bootloader level, mini has been stuck with an older bootloader that takes 4KB of FLASH at some slow sketch transfer speed. Nano uses a more recent bootloader, 2KB in size, and loads sketch a bit faster. UNO/UNO SMD uses the most recent bootloader, i.e. optiboot (although I don't know what version). It has 512B of bootloader and uploads sketch at 115200, fastest among all, although it doesn't enable all 8 analog pins. There is no out of the box option for the fastest/smallest bootloader and all 8 analog pins. So I asked you why you needs all 8 analog pins.

Couldn't boards.txt have this line changed from

uno.build.variant=standard

to the nano's?

nano.build.variant=eightanaloginputs

ending up with this: uno.build.variant=eightanaloginputs

The only difference between the standard variant and the eightanaloginputs variant is it sets NUM_ANALOG_INPUTS to 8. variants/eightanaloginputs/pins_arduino.h

#include "../standard/pins_arduino.h"
#undef NUM_ANALOG_INPUTS
#define NUM_ANALOG_INPUTS           8

So if your project doesn't use that macro then there's no difference. That macro isn't used by the Arduino core and the only built-in library that uses it is Firmata, some 3rd party libraries might use it.

Tonight I tested this with my nano. I first flashed it with optiboot used by UNO. Then I selected UNO from IDE and tried to read A7. It was successful. I could read 5V, GND, and VIN, which is ~4.6V. All is good. Just flash optiboot or use arduino as isp and select board "UNO". You get minimal bootloader size, fastest upload, and all 8 analog pins. Now I just have to print a tiny sticker that says "UNO" to place on my nano.

I'll surest adding an ISP header on your board. It makes it much easier to do any code changes without having to buy an extra adapter. I've been using the Sneaky footprint tutorial on my boards. this means I can just press-fit the programming header, and pull it out if I don't need it.

You don't actually need a bootloader, but it can be useful when you're prototyping. My latest core project, the MiniCore (Github link) incorporates a bootloader that lets you read and write to the flash memory while the program is running on the microcontroller, and still only takes up 512B of space :)

If you want to keep your board as clean as possible this core lets you use the 8 MHz and the 1 MHz internal oscillator if speed and super-accurate timing isn't important. This will also free up two digital pins that the original Arduino core haven't mapped to any "Arduino pins". By looking at this ATmega328* pinout you can see that PB6 and PB7 is available for use, and I've mapped them to digital pin 20 and 21 :)

BTW the MiniCore supports all variants of the ATmega328, including the P, PA and the non-P model, as well as the rest of the chip family.