DED9

Complete AVR Microcontroller Programming Course

One of the main and important needs of students, researchers and those interested in the fields of electronics and robotics is the construction of various control and programmable devices and equipment such as timers and clocks, as well as creating the possibility of controlling appliances via the Internet or SMS and controlling servers, for this purpose, microcontrollers is used AVR microcontrollers are a new type of microcontroller that Atmel introduced to the electronic market.

AVR microcontroller is a widely used and common microcontroller that can be programmed using various compilers such as Atmel Studio. In this article we will get to know the applications of the AVR microcontroller, how to program it, and the benefits of using the AVR microcontroller.

Microcontroller

 

Features of AVR microcontroller

Among the prominent features of AVR microcontrollers are high performance, high speed and low energy consumption. These parts can stop the machine cycle and execute the pipeline operation with the clock cycle. Most AVR microcontroller instructions are single cycle. The unit cycle can advance the execution of one instruction and complete the reading of the next instruction. There are a total of 32 general-purpose registers in AVR microcontrollers, the first 16 registers (R0-R15) cannot be directly and immediately operated.

Meanwhile, the avr microcontroller has the highest performance and performance in CPU. Small codes are used in its programming. These chips are highly upgradeable and their self-programming memory has many uses. Also, this microcontroller has the best MCU for flash memory.

How to program avr microcontroller?

AVR microcontrollers are programmed with different languages and different compilers. One of these languages is the C language in CodeVision software, a programming compiler. Other famous and reliable compilers include Atmel Studio, BASCOM, IAR, CodeVision AVR C Complier, Arduino IDE, and WinAVR. If you intend to learn avr microcontroller programming in C language, follow this section completely.

Introduction of C language

C is a simple and powerful programming language designed by Dennis Ritchie in 1972. This language is one of the intermediate level languages among programming languages. The C language is a structured programming language in which a highly readable program can be written using repetition loops (such as for and while).

Features of C language

As we mentioned, C language is a flexible and powerful programming language. There is a close connection between C language and Assembly. The number of keywords in this program is 30, which is less than other programs. C programming language is case sensitive. The important thing here is that all keywords in this language are written in lowercase letters. For example, int is a keyword, but INT is not a keyword.

Every command in C language is “;” ends In this programming language, the maximum length of a command is 255 characters. Each command can be continued on one or more lines. Several commands can be typed in each line. In C language, descriptions can be placed between */ and */ or written after //.

Data types in C language

In the C language, there are four data types that are associated with the prefixes Short, Long, Signed, and Unsigned. The following are also used to store different input characters in C language:

With the information in this section, you can start programming the AVR microcontroller in a preliminary way and increase your learning step by step. Our suggestion for you to learn better and more complete AVR microcontroller programming is to use extracurricular training. In this website, the training of AVR microcontroller with Atmel Studio, CodeVision and Keil Compiler is fully provided for you.

Advantages of AVR microcontroller programming

If you are planning to choose your AVR microcontroller, but you are still not convinced about this, it is better to pay attention to the contents of this section. In this section, some important advantages of using AVR microcontroller are listed for you:

What are the uses of avr microcontroller?

AVR microcontroller programming allows it to be used in a variety of applications, including security, propulsion, and entertainment systems. Atmel, one of the leading AVR microcontroller compilers, has recently launched a new publication, Atmel Automotive Compilation, to help developers with automotive applications. Some of the current applications of this microcontroller are in BMW and TRW.

Various companies manufacture avr microcontroller boards for use by hobbyists, robot builders, testers, and small system developers such as BasicX and Oak Micros. Schneider Electric used an AVR microcontroller to produce the M3000 motor and motion control chip, which has an Atmel AVR core and an advanced motion controller for use in motion applications.

Various AVR microcontroller compilers

For AVR microcontroller programming, different compilers have been published all over the world.

1. Atmel Studio

Atmel Studio is an integrated development platform or IDP that you can use to develop and troubleshoot AVR microcontrollers. This compiler is one of the most powerful AVR compilers in the world, but at the same time it is more complicated than other compilers. This compiler can be downloaded for free on the Internet. In addition to AVR microcontrollers, this compiler also has the ability to program ARM microcontrollers. In the following tutorial, you can access the complete Atmel compiler tutorials.

2. BASCOM Compiler

This compiler is a product of MCS Electronics in the Netherlands that supports the QBASIC language. The trial version of this compiler can be downloaded from the company’s official website. With this version it is possible to compile up to 4KB which is very suitable for chips like Atmega48 and TinyAVR series.

 

3. IAR Embedded Workbench AVR Compiler

The acronym IAR stands for Anders Rondgren Engineering Company. IAR Systems is a Swedish computer software company that provides embedded systems development tools to users. IAR is one of the powerful compilers in AVR microcontroller programming that supports most of the microcontrollers in the market.

Microcontroller manufacturers usually have examples in their source code in this language. Usually, there are not many internet resources for this programming environment and maybe that is the reason why they don’t go to it much. The price of this software varies from 900 to 3 thousand dollars.

4. Codevision (CodeVision AVR C Compiler)

This compiler is a product of HP InfoTech. This compiler supports C language. HP InfoTech company has introduced different types of this type of compiler. The free version of this compiler can compile up to 2 KB. Other versions include advanced and professional versions. The difference between these two versions is fully explained on the manufacturer’s website. You can use the complete tutorials on the Codevision compiler by referring to the link below.

5. WinAVR Compiler

One of the world’s most powerful compilers for programming avr microcontrollers is WinAVR and it has many fans all over the world. This compiler is completely free. In general, it can be said that most professional programmers of AVR microcontrollers use this compiler. This compiler gives you a faster and more optimized program in the end because it generates less HEX code.

6. Arduino (Arduino IDE)

Open source Arduino software makes coding and uploading code on the circuit easy. This software is applicable for Windows, Mac and Linux operating systems. Also, Arduino software is compatible with all Arduino boards. This programming environment is produced using Java language and based on processing, avr-gcc and other open source software.

Programming principles in Arduino software are largely similar to C and C++; Although some commands, commands, functions and libraries have specific changes made for Arduino. The general process of working with this software is that first commands are placed in the text editing window. Then they are compiled and loaded on the Arduino microcontroller board. Before uploading, it is necessary to connect the Arduino board to the computer through the USB port.

 

AVR microcontroller programming and troubleshooting interfaces

There are many ways and methods to program and debug AVR microcontrollers, and each of them has its own method. In this section, we have described the popular programming interfaces used for microcontroller troubleshooting.

1. ISP programming interface

The In-System Programming method, which is abbreviated as ISP, works by the serial side communication bus protocol plus sending a signal with a rising or falling edge based on RESET, and is the most widely used AVR microcontroller programming method. As long as the microcontroller’s ISP pins are not connected to something that interferes, the avr microcontroller can remain in place on the PCB. All that is needed is a 6-pin terminal and a programming converter.

2. PDI programming interface

The programming and debugging interface of microcontrollers (The Program an Debug Interface) is abbreviated as PDI, which is one of the features of AVR microcontrollers for programming by an external tool and on-board troubleshooting. This programming interface is different from the JTAG part and is designed for XMEGA family devices.

3. HVSP programming interface

The High Voltage Serial Programmer, abbreviated as HVSP, is mostly supported in smaller AVRs. An 8-pin chip leaves no more unique signal combinations to put the AVR into programming mode. However, the avr should only be seen at 12 voltage during programming and should never be at this voltage during normal time.

4. HVPP programming interface

High Voltage Parallel Programmer is a programming method in which information is transferred as 8 separate bits through a port. According to the instructions of the manufacturer, a voltage of 12 volts should be applied to the RESET pin. This method is used when the access of the chip from ISP and JTAG is limited, when the user is forced to program the processor. Unlike ISP, which requires 6 cables to program the AVR microcontroller, in this method, almost all the bases of the desired chip are used. The advantages of this include high speed and full access to the chip. Only programmers like STK500HV support this method.

 

5. Bootloader programming interface

Most avr models can reserve a bootloader area from 256 bytes to 4 KB where reprogramming code can be written. During a reset, the bootloader runs initially and is programmed by the user to determine whether to reprogram or return to its original program. This code can be reprogrammed via any programming interface, or it can read an encrypted binary code via an Ethernet adapter such as PXE. Atmel has written the code for many bus interfaces through this programming interface.

6. ROM programming interface

The AT90SC series of AVR microcontrollers are available with the company’s ROM programming interface. Due to the very high initial cost and minimum order quantity, Mask-ROM will only be cost-effective for parties to run in high volume productions.
Debugging and troubleshooting interfaces

After programming the AVR microcontroller, sometimes we need to troubleshoot our programming interface. Avr offers several options for debugging, mostly including on-chip troubleshooting while it is in use on the target system.

DebugWIRE option

Atmel’s solution for debugging microcontrollers is DebugWIRE, which provides on-chip debugging capabilities via a microcontroller socket. This way is especially useful for parts that have a limited number of pins and cannot provide the four spare pins required for JTAG. DebugWIRE was developed after the original JTAGICE and is now widely used in electronics.

JTAG option

The Joint Test Action Group (JTAG) provides access to the AVR’s on-chip troubleshooting functionality while the THR is running on the target system. JTAG provides users with access to internal memory and registers, failure detection on code, and single-step execution to observe system behavior. Atmel offers a range of JTAG adapters for the AVR. Atmel-ICE is the company’s latest adapter that supports ISP, JTAG and PDI interfaces.

JTAGICE mkll connects to a PC via USB and supports both JTAG and the newer debugWIRE interface. Many third-party clones of the Atmel JTAGICE mkll device began sending data after the Atmel communication protocol was released.

AVR Dragon is a convenient and inexpensive alternative to JTAGICE mkll, which is made for special purpose components. The AVR Dragon offers in-system serial programming, high-voltage programming, as well as parallel programming and JTAG emulation for parts with 32KB or less of program memory.

The JTAGICE adapter connects to a PC through a standard serial port. Although the JTAGICE adapter has been declared “end of life” by Atmel, it is still supported in AVR Studio and other similar tools.

 

avr microcontroller programming; A path-breaking method in the electronics industry

AVR microcontrollers can be considered as a small computer. The main application of microcontrollers in a system is to control and process system parameters. In this way, the input parameters are processed and their results are displayed.

 

 

 

 

 

 

 

 

Die mobile Version verlassen