Hi there
I'm really new to micro-controllers. what are the various ways that I can program an ATmega328p?
Do I necessarily need an arduino board to program an ATmega328p?
Hi there
I'm really new to micro-controllers. what are the various ways that I can program an ATmega328p?
Do I necessarily need an arduino board to program an ATmega328p?
Hello carl_gem
First of all, good questions, To program an ATmega328p using Arduino IDE, a knowledge of C is needed, Most people will get an Arduino Uno 3 to start. But since this is open hardware, there are many clones to look at adding features like wireless, LED's, switches, and other sensors. For a small list, see arduino Clones? The only downside is soldering which can be a change to some. What do they have in common? Most of them use the ATmega328p chip. If you are just starting, the chip is really cheap! But you have nothing to use with it
What to know about it:
Before anyone says "But I do this another way", I have chosen what I think is a simpler less confusing way.
For references:
To buy: https://www.sparkfun.com/products/9061
Other choices (remember avoid square) https://www.sparkfun.com/categories/21
To use another Arduino to program How to use Arduino as AVR Programmer (for ATMega328p)
To breadboard (simple) and play with from PC using AVRDUDE avr - Programming a ATmega328P on a breadboard - programmer cannot connect - Electrical Engineering Stack Exchange
Tutorial of programming in C Video: Learning to program for the ATmega328p Part I | Hackaday
Clem
Please mark "correct" if this answers your questions as this help others too. If you have other related questions post here. Otherwise kindly open a new question. Enjoy the process and have fun.
Editted per Peter Oakes correction
The answer given by clem57 is simply perfect
Anyway if you are new to microcontroller I suggest you to start with the arduino (uno) board because with it you have all you need to start and you can easily learn to program using the simplified C of arduino. After this you can use a more sophisticated C or assembly (using AVR studio), you can also use the arduino board to program other microcontrollers like the attiny family.
You can start without the arduino board but will need other hardware to program it.
I started few years ago with the arduino uno board (The only thing that I hate of the arduino board is that don't fit into it the strip line connector, except this it's a very good starting point)
When you say 'program' a microcontroller, if you mean writing a program and then compiling it, then you can use an Arduino IDE or the AVR Studio to write and compile a program. There is a bulk of libraries available for helping you accomplish your ask in the Arduino IDE so for beginners that should be a better bet.
Then comes the act of putting your program onto the microcontroller. There are two options in that case
1. The arduinos that you buy out use something called a bootloader which allows you to program the microcontroller without any 'programming hardware'. You basically send the program over a serial link(usually over USB) and the microntroller executes the program when you reset it. If you want this approach then you need a bootleader which is available with each Arduino IDE download. Its simple and there is extensive documentation on bootloaders available online.
2. The other method is using an In-System Programmer or ISP. There is a six pin header on an arduino board that exposes the SPI pins of the AVR and you can program it using an ISP which is basically a separate microcontroller board that can send your program over ISP to the AVR. You can use an existing Arduino board as an ISP that you can google "Arduino as ISP" to get more details. There are other specialised hardware like the AVR Dragon but I recommend looking at DIY methods for beginners. The software that is used(in arduino as well) is called AVR Dude and you can google it for more info.
Hope this helps.
The Crystal/resonator needs to be the speed you want to run at, not 32K which is often used for Time keeping rather than time base for some MPU's (Specifically the ATMEGA 328 does not use a 32K crystal)
so the crystals would be 8, 12, 16, or 20Mhz depending on the voltage your running the MPU at (8Mhz is low volts/power, 20Mhz you will be at the full 5V and higher power)
otherwise a great response
Hi clem57 Good answer, but not understand about 32K Crystal, i'm checking the datasheet of the ATMEGA328 and supports up to 20 MHz and apparently the 32K of flash memory.
Hi, I use the 328 in a lot of applications, because of its size, speed, and on board resources make it a very versatile solution to many situations. I buy Arduino platforms for doing a good deal of the prototyping because they come with built in serial to USB making a simple place to have debug information output. I skip using the Arduino interface for most of my work, because it doesn't do a good job of managing interrupts the way I want. I use a programmer that I purchased through the Atmel site. Either the AVR Mark2 or the JTAG. The mark2 is my workhorse for programming in circuit both the application code and the EEPROM.
Jack
Another good cheap website is electrodragon.com
I have seen a bunch of these sites. I have ordered stuff from MiniInTheBox on several occasions. The prices are great, but many times the order gets stuck for a few weeks in customs from China. So if you don't need it fast, this is a great solution.
Jack