Programing a Atmega328P

Hi,

I am building a new board based on the Atmega328P (similar to the Nano) to save space and money on each board can I use this PCB to program my board if I make a header with TX/RX/GND

Will it also give me a arduino nano like debug output?

P.S. I do realise I will have to program the 328P with the bootloader code

Steve

1 Like

yes, you can use Serial.print() in your sketch and view the results in the IDE Monitor as with standard Uno/Nano. You also can use any other terminal program for it rather than Arduino Serial Monitor.

this has absolutely nothing to do with the use of the Serial prints in the code

I would buy a USB to serial adapter (FTDI) that breaks the DTR pin out to the header with Vcc, ground, TX and RX. Then add a 0.1uF cap from the programming header DTR pin to the processor reset pin. That will give you the auto-reset capability so that you do not have to manually reset the processor during upload.

I like the MiniCore core to bootlaod my mega 328 processors. That core makes it easier to choose the bootload options like clock frequency, clock source, BOW, ... The MiniCore core is available through the IDE boards manager.

I realise the bootloader has nothing to do with the printing / monitoring, I only mantion it becuase that board I linked to will not program the arduino via the IDE unless I have the bootloder on it. Am I correct in saying this?

Steve

you can program it with ISP programmer. You not need bootloader for it.

Would using a FTDI cable like THIS and adding a the cap to the RESET pin (DTR pin) work?

So I'd have a six pin header on my board that allows my to program the Atmega328P via the arduino IDE when set to use "Nano" board and also use the serial monitor?

Steve

The pinout of that cable is a mystery, I would not use it. I was thinking more like these USB to serial adapters. The break out the DTR pin and also have both 5V and 3.3V outputs.

When I build any mega328 standalone projects, I add a 5 pin programming header that has Vcc, ground, RX, TX and DTR pins on the header to use for serial programming with the IDE. Like I said, I use the MiniCore core to bootload my mega328 stand alone projects, so the board that I choose when programming is the board that the bootloader supports. If you bootload for a Nano, choose Nano.

Thanks for the help, another question, I am looking for a 16mhz SMT crystal with biuilt in caps, can anyone recomend one as the ones I'm finding all require exteral caps.

Thanks

Steve

Why not use a Pro Mini and place it on your board with header sockets.
It would make your job easier and using relatively cheap controller modules.

Can we please have a circuit diagram?
What is the project and why do you need to go small?

Have you made and tested a protoboard prototype, before going to PCB?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Do you really need 16MHz? I have found that I can get along with 8MHz for most of the stand alone stuff that I do. So I bootload with an 8MHz internal clock bootloader using MiniCore. Then I need no external crystal or resonator and I gain 2 GPIO pins. The crystal pins can be used as regular digital pins 20 and 21.

Why does that matter?

You probably want to search for a 16MHz SMD oscillator instead of a crystal.

Sure. If you do that, you have to set CKSEL bits to "External Clock". It will be more expensive, and probably larger, than a bare crystal (with caps :slight_smile: ). But it is an option.

Also is there a specific reason for designing a new circuit with a processor that is so outdated?

I think this is the type that most people use for USB-to-UART.

https://www.ebay.com/itm/224973499654

I think this is equivalent to your Sparkfun board, but cheaper. But I think both require a bootloader to program the 328P. If you don't have a bootloader, then you need a programmer device, or an Arduino of some kind acting as a programmer. It would connect to different pins on the 328P (the SPI pins and reset).

Anyway, these are as little as $1 from China. And they have a 3.3V - 5V jumper which controls Vcc as well as all the I/O lines. The header is the same layout as the Pro Mini. Speaking of which, you might want to look at using a Pro Mini. You can remove the power indicator LED and even the regulator, which leaves you with the processor and its capacitors, and the resonator. Comes in 3.3V 8MHz and 5V 16MHz versions, and will have a bootloader.

Space, ease of layout, less components, preference

It's the same as the Nano, it's easy to place (solder) I can use the arduino IDE. Happy to look at alternatives as long as it can look at an arduino so I can use the IDE, get serial debug, not BGA so I can solder it easily.

Thanks

Is the minicore an add in board to the IDE? I couldn't see it on the standard list.

Running the minicore and 8Mhz sounds like good idea :+1: I assume it behaves e.g. programmes through IDE and serial debug just like any other nano like arduino? (with the addition of the adapter cable / board)

Thanks

Hi, @scarr999
Can you answer post #9 please?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Yes, you add that core using the boards manager in the IDE, Tools, Boards, Boards Manager. See how to use the board manager.

That is correct. You program the mega328 just the same and every thing works the same.

Thanks groundfungus, you have been very hepfull. if you don't mind I will show you what I intend to do as I go along just in case I miss something. I will send schematic and interface board I intend to use.

Steve