{"id":165,"date":"2012-12-20T13:40:31","date_gmt":"2012-12-20T12:40:31","guid":{"rendered":"http:\/\/www.kanda.com\/blog\/?p=165"},"modified":"2018-01-31T14:12:24","modified_gmt":"2018-01-31T13:12:24","slug":"avr-microcontroller","status":"publish","type":"post","link":"https:\/\/www.kanda.com\/blog\/microcontrollers\/avr-microcontrollers\/avr-microcontroller\/","title":{"rendered":"What is AVR microcontroller?"},"content":{"rendered":"

An AVR microcontroller is a type of device manufactured by Atmel, which has particular benefits over other common chips, but first what is a microcontroller?<\/p>\n

The easiest way of thinking about it is to compare a microcontroller with your PC, which has a motherboard in it. On that motherboard is a microprocessor (Intel, AMD chips) that provides the intelligence, RAM and EEPROM memories and interfaces to rest of system, like serial ports (mostly USB ports now), disk drives and display interfaces. <\/p>\n

A microcontroller has all or most of these features built-in to a single chip, so it doesn’t need a motherboard and many components, LEDs for example, can be connected directly to the AVR. If you tried this with a microprocessor, bang!<\/p>\n

<\/p>\n

AVR microntrollers come in different packages,some designed for through-hole mounting and some surface mount. AVRs are available with 8-pins to 100-pins, although anything 64-pin or over is surface mount only. Most people start with a DIL (Dual In Line) 28-pin chip like the ATmega328 or the 40-pin ATmega16 or ATmega32.<\/p>\n

\"ATmega16<\/p>\n

PC microprocessors are always at least 32-bit and commonly now 64-bit. This means that they can process data in 32-bit or 64-bit chunks as they are connected to data buses this wide. The AVR is much simpler and deals with data in 8-bit chunks as its data bus is 8-bit wide, although there is now an AVR32 with 32-bit bus and an ATxmega family with a 16-bit data bus.<\/p>\n

A PC has an operating system (Windows or Linux) and this runs programs, such as Word or Internet Explorer or Chrome that do specific things. An 8-bit microcontroller like the AVR doesn’t usually have an operating system, although it could run a simple one if required, and instead it just runs a single program. <\/p>\n

Just as your PC would be useless if you didn’t install any programs, an AVR must have a program installed to be any use. This program is stored in memory built-in to the AVR, not on an external disk drive like a PC. Loading this program into the AVR is done with an AVR programmer, usually when the AVR is in a circuit or system, hence AVR ISP or AVR In System Programmer. <\/p>\n

AVR ISP for AVR Microcontroller Programming<\/p>\n

\"AVRISP
\n<\/a><\/p>\n

So what is a program? A program is a series of instructions, each very simple, that fetch and manipulate data. In most applications where you would use an AVR, such as a washing machine controller for example, this means reading inputs, checking their state and switching on outputs accordingly. Sometimes you may need to modify or manipulate the data, or transmit it to another device, such as an LCD or serial port.<\/p>\n

A series of simple binary instructions are used to do these basic tasks and each one has an equivalent assembly language instruction that humans can understand. The most basic way of writing a program for an AVR is to use assembly language (although you could write binary numbers if you want to be pedantic). <\/p>\n

Using assembly language allows you to understand far more about the operation of the AVR and how it is put together. It is also produces very small and fast code. The disadvantage is that you as the programmer have to do everything, including memory management and program structure, which can get very tedious.<\/p>\n

To avoid this, high level languages are increasingly being used to write programs for the AVR, C in particular but also Basic and Java derivatives. High level means that each line of C (or Basic or Java) code can translate into many lines of assembly language. <\/p>\n

The compiler also deals with the program structure and memory management so it is much easier. Commonly used routines, such as delays or maths, can also be stored in libraries and reused very easily. The C compiler also deals with larger numbers that take up more than a byte (8-bits).<\/p>\n

In my opinion, writing AVR programs in C is like driving a car. Yes you can do it very easily but if something goes wrong you haven’t got a clue how to fix it and you can’t deal with tricky situations like icy roads. Starting with assembly language and writing some simple programs lets you understand what is going on “under the hood” so you know how it works and can get the most out of it. Then swap to C by all means but at least you know how the AVR microcontroller fits together and its limitations.<\/p>\n

Learning AVR Microcontrollers
\n\"AVR
\n<\/a><\/p>\n

<\/p>\n

As well as having reprogrammable code memory for your program, the AVR has a second memory called EEPROM where you can store user data, like serial numbers, calibration data and other information that needs to be preserved. It is accessed by instructions in your program.<\/p>\n

AVRs also have an I\/O space, which is used to control the hardware of the microcontroller and store temporary data used by your program. The hardware includes ports, ADC, communication interfaces like I2C (2-wire interface), SPI and UART (serial port), timers and watchdogs that recover from system crashes. All these peripherals are controlled from your program using special instructions. A lot of AVR code programming is about how to setup and control this hardware interface.<\/p>\n

Kanda AVR kits, like STK200 and our other AVR training kits, use assembly language to teach you all about the AVR and its hardware setup before moving on to C programming. They also cover the hardware circuit requirements needed to interface with the AVR microcontroller, once you move beyond the AVR board supplied and want to develop your own circuits.<\/p>\n

AVR Microcontrollers For Beginners
\n\"AVR
\n<\/a><\/p>\n

A final word about Arduino. This is a simplified development system for microcontrollers. It is based on the AVR microcontroller but this is pretty well concealed. It is great for developing a quick project but it won’t really teach you about AVRs or how to program them using real development tools.<\/p>\n

Related Information<\/strong><\/p>\n

Arduino Kits Explained<\/a><\/p>\n

What is Arduino?<\/a><\/p>\n

What is the best AVR Programmer?<\/a><\/p>\n

AVR Microcontroller Training Kit<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"

An AVR microcontroller is a type of device manufactured by Atmel, which has particular benefits over other common chips, but first what is a microcontroller? The easiest way of thinking about it is to compare a microcontroller with your PC, which has a motherboard in it. On that motherboard is a microprocessor (Intel, AMD chips) … Continue reading What is AVR microcontroller?<\/span> →<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[42],"_links":{"self":[{"href":"https:\/\/www.kanda.com\/blog\/wp-json\/wp\/v2\/posts\/165"}],"collection":[{"href":"https:\/\/www.kanda.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kanda.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kanda.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kanda.com\/blog\/wp-json\/wp\/v2\/comments?post=165"}],"version-history":[{"count":11,"href":"https:\/\/www.kanda.com\/blog\/wp-json\/wp\/v2\/posts\/165\/revisions"}],"predecessor-version":[{"id":1281,"href":"https:\/\/www.kanda.com\/blog\/wp-json\/wp\/v2\/posts\/165\/revisions\/1281"}],"wp:attachment":[{"href":"https:\/\/www.kanda.com\/blog\/wp-json\/wp\/v2\/media?parent=165"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kanda.com\/blog\/wp-json\/wp\/v2\/categories?post=165"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kanda.com\/blog\/wp-json\/wp\/v2\/tags?post=165"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}