1
\$\begingroup\$

So I saw a post talking about the commercial feasibility of an Arduino (http://electronics.stackexchange.com/questions/11333/commercial-use-of-arduino-is-it-suitable) . From this it said a great idea would be writing your own AVR Program i believe.

What does it mean to:

1) Write an AVR Program? What is an AVR Program? 2) Program your own microcontroller?

Is it possible to make your own microcontroller and how would you do this? Would you still use something such as an ATMEGA? What would this change and how would you "upload" an AVR to this?

Edit (after Comment #1): My questions is would i still use the Arduino or would it be better for me to buy ... a different? microcontroller and program that? To refine my other question, how would you program ... a microcontroller? what interface would be used to upload code?

\$\endgroup\$
  • \$\begingroup\$ "AVR" is just another name for the processor on the Arduino. There are lots of different AVR processors, but the Arduino only uses a couple of different AVR types. Also, the words 'microcontroller' and 'processor' are basically synonymous for your purposes. You wouldn't "make a microcontroller" using an ATMEGA, b/c the ATMEGA is already a microcontroller. \$\endgroup\$ – JustJeff Apr 6 '12 at 23:55
  • 1
    \$\begingroup\$ You really need a better title. \$\endgroup\$ – Kellenjb Apr 7 '12 at 1:12
  • \$\begingroup\$ sorry. suggestions will be gladly accepted \$\endgroup\$ – Eiyrioü von Kauyf Apr 7 '12 at 1:24
  • \$\begingroup\$ I was going to recommend something, but I am confused as to what your question really is, you seem to be jumping around. Format your title as a question and it will easier to figure out what you are asking. \$\endgroup\$ – Kellenjb Apr 7 '12 at 1:57
2
\$\begingroup\$

It's a broad question. I don't think the previous question was meant to imply that an Arduino isn't a 'real' or 'professional' development platform. It has its niche. Every microcontroller has its niche - you have to choose one that helps you do what you're trying to do. Does that sound vague? Yes. Because it all depends on what you're trying to do.

So let's back up - what IS the Arduino compared to everything else? I'll split it up into hardware and software.

As far as hardware goes the Arduino is a development board. There are lots of development boards out there - tons of them. They each are built around one or several microcontrollers. They are, to a certain extent, meant to be somewhat generic in function - you need to be able to use them to develop for just about any application. But they can also have a focus - you might see development boards with HDMI and Ethernet controllers - these are obviously meant to help people develop applications for networking or visual applications. The Arduino is a solid development board, but it has very few neat features. The approach behind Arduino is a wide-open sandbox - that's why there's so many shields available.

So development boards are built around microcontrollers. The Arduino is built around the AVR ATMega328. This is a specific microcontroller made by Atmel. It is one of Atmel's 8-bit microcontrollers. It is aimed at general purpose embedded applications that don't require a whole lot of bells and whistles or lots of I/O (it's rather limited in the number of pins it has). To put this in perspective, Atmel also offers 32-bit ARM-based offerings - this is a type of microcontroller you might find in a router that runs Linux. There are, of course, many different microcontroller manufacturers - all offering differnt microcontrollers focused on certain applications - automotive, networking, DSP, etc.

Now there's the question of the software - what does it mean to write an AVR program? Well, everything you write for an Arduino is an AVR program - it's just hard to tell. Arduino comes with a framework that basically hides a lot of the complexity of microcontroller programming from you. Typically, writing any microcontroller code (including AVR programs) involves lots of playing with bits in registers, keeping track of timing, etc. It's very low-level and there's a lot to keep track of.

In a broader sense, microcontrollers are typically programmed in a variant of C. I say a variant because every microcontroller needs a special C compiler with its own rules. So every different chip has its own variant of C. There aren't earth-shattering differences between each of them, but you can get tripped up on the differences if you're not careful.

How do you program them? There's lots of ways, but generally nowadays chips tend to program themselves. That's no joke - most programmers just implement a special kind of serial communication that lets them be programmed by one of several devices. This is called In-System Programming. You program microcontrollers with a variety of devices - they can be $5 USB dongles, parallel port devices or $1200 JTAG adapters. Typically you need a specific programmer for a specific line of chips. That is to say, you can buy a JTAG that will program most to all ARM chips, and you can find programmers that will program most if not all AVR chips.

So programming your own microcontroller basically means you 1) Select a microcontroller you want to use, 2) find a good development board for it, 3) find some sort of programmer - either an In-System Programmer, or JTAG or something else, 4) figure out what compiler you need, what code editor to use, etc. (Arduino of course, provides all of this, so it's easy). Then, you read the chip's data sheet and figure out where to start.

\$\endgroup\$
  • \$\begingroup\$ .....now how would i start doing this? \$\endgroup\$ – Eiyrioü von Kauyf Apr 7 '12 at 1:24
  • 1
    \$\begingroup\$ @user997301 Well the first step is to actually get an AVR chip. I myself started with ATmega162 and ATmega 16. They have a reasonably wide amount of peripherals (remember, microcontroller isn't just a processor, it's a whole computer) and aren't too expensive for a beginner. Next step is to get or make a programmer. The official one is AVRISP mkII, but you can make one yourself (just type into Google AVR programmer and you'll get tons of results). \$\endgroup\$ – AndrejaKo Apr 7 '12 at 6:37
  • \$\begingroup\$ @user997301 This article is nice for beginners looking for a programmer and here you'll find how to make the most basic board in which you could program an AVR microcontroller. \$\endgroup\$ – AndrejaKo Apr 7 '12 at 6:38
1
\$\begingroup\$

Write an Avr program means writing code and loading it to the AVR microcontrollers (*AVR family has many series of microcontrollers such as ATMEGA103, ATMEGA128, ATMEGA1280, ,,,,,, etc and also the popular controllers such as TMEGA8, ATMEGA16 etc....) using the softwares like AVR STUDIO, CODE VISION AVR etc..etc...

Program you own microcontroller means that it is a phrase which tells you to " take your preferred microcontroller, choose your code writing software, and then write your code, load it on to the microcontroller and finally see the application "

for example im using the ATMEGA 8 CONTROLLER FOR FLASHING the lEDs

I used the AVR Studio 6. software for coding, and PRO ISP toload the code on to the micrcontroller

the code is as follows:

#include<avr/io.h>
#include<util/delay.h>

int main()
{
DDRB=0b11111111;
DDRD=0b00000000;


    while(1)
    {
        if (PIND=0b00000001)
        {
            PORTB=0b11111111;
            _delay_ms(100);
            PORTB=0b00000000;
            _delay_ms(100);
        }
    }
    return 0;
}
\$\endgroup\$
  • \$\begingroup\$ haha this is quite long ago - i've already programmed quite a few microcontrollers by now :) \$\endgroup\$ – Eiyrioü von Kauyf May 8 '15 at 15:48
  • \$\begingroup\$ @BoopathySuntharan Please don't write in all-capitals. It's bad etiquette on the web. Fair warning. \$\endgroup\$ – Nick Alexeev May 10 '15 at 19:48

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.