Menu English Ukrainian russian Home

Free technical library for hobbyists and professionals Free technical library


ENCYCLOPEDIA OF RADIO ELECTRONICS AND ELECTRICAL ENGINEERING
Free library / Schemes of radio-electronic and electrical devices

Programming MK AVR in Ubuntu OS. Encyclopedia of radio electronics and electrical engineering

Free technical library

Encyclopedia of radio electronics and electrical engineering / Microcontrollers

Comments on the article Comments on the article

I put myself such an OS - Ubuntu 9.04. Of course, you can’t really play with toys in it, it’s basically only for work.

Well, I decided to try programming AVR controllers in it.

On the Internet, in principle, there are a lot of all sorts of things that will help in mastering AVR programming under Linux.

But as usual, I was faced with the fact that a lot of things, well, nothing really. Everywhere it is advised to install Eclipse or KontrollerLab (as it got me).

Well, you certainly guessed that something went wrong with me with them as we would like. In general, by the method of guesswork and highly intelligent poke, I began to experiment. And here's what I came up with...

Open the Sinaptic package manager and type gcc-avr in the search box. We mark to install gcc-avr, avr-libc, avrdude.

You can of course do it like this:

$sudo apt-get install gcc-avr avr-libc avrdude

Well, to start, everything that is needed seems to be installed.

Next, create a folder called AVR in the root of the system (folder path: /AVR)
As an editor, you can use nano (in the terminal we prescribe nano),
but I used the usual text editor gedit (in the terminal we write $ sudo gedit)
In it we will write our code, for example:

#include

#include
#include
int main (void)
{
DDRx=0xFF;
while (1)
{
PORTx=0xff;
_delay_ms(100);
PORTx=0x00;
_delay_ms(100);
}
}

Next, save our text with the main.c extension in the AVR folder (file path: /AVR/main.c).

Now let's move on to compiling the code.
Let's start the terminal and write the following code:

$avr-gcc -mmcu=atmega8 -I. -gdwarf-2 -DF_CPU=8000000UL -Os -o /AVR/main.o /AVR/main.c

I searched for the right line for a long time, in the end I just took it from WinAvr :).

avr-gcc - compiler, -mmcu=our controller (currently atmega8), -DF_CPU=clock frequency in Hz, -Os-code optimizer, -o-OUT, /AVR/main.o-output file with extension .o which we get from .c, /AVR/main.c is our si file.

Programming MK AVR in Ubuntu OS. Terminal screenshot

Do not forget to work as root, otherwise the system will not let you.

Enter and if we go to our /AVR directory, we will see a file with the .o extension.

Next, in the terminal (aka console), enter:
$avr-objcopy -O ihex /AVR/main.o /AVR/main.hex

Well, I won’t explain for a long time, I’ll just say that we are moving our main file from main.o to main.hex.

Well, our firmware is ready to be uploaded to our ATmega8.

Of course, we need a programmer.

We will use the programmer stk500v2 by Petka (It works just fine, fills it instantly, does not fall off the port, though I used it instead of the FT232 CP2102. Thank you so much for the schematic and firmware.)

Let's open the terminal and run the avrdude utility, which will work for us under the console:

$avrdude -c stk500v2 -pm8 -P /dev/ttyUSB0 -U flash:w:/AVR/main.hex

Programming MK AVR in Ubuntu OS. Terminal screenshot

Programming MK AVR in Ubuntu OS. Uploading the program to the controller

In the end, everything worked out!

Of course, the program was flooded with another one and its volume was 5 kB, but it was filled in less than 4 seconds.
As you know, there are also GUI shells for avrdude, but this is a completely different story that I will tell in another article. :)

PS With AVR910 they say that it works fine, but I haven't tried it myself.

Author: Efimov Valentin; Publication: cxem.net

See other articles Section Microcontrollers.

Read and write useful comments on this article.

<< Back

Latest news of science and technology, new electronics:

Machine for thinning flowers in gardens 02.05.2024

In modern agriculture, technological progress is developing aimed at increasing the efficiency of plant care processes. The innovative Florix flower thinning machine was presented in Italy, designed to optimize the harvesting stage. This tool is equipped with mobile arms, allowing it to be easily adapted to the needs of the garden. The operator can adjust the speed of the thin wires by controlling them from the tractor cab using a joystick. This approach significantly increases the efficiency of the flower thinning process, providing the possibility of individual adjustment to the specific conditions of the garden, as well as the variety and type of fruit grown in it. After testing the Florix machine for two years on various types of fruit, the results were very encouraging. Farmers such as Filiberto Montanari, who has used a Florix machine for several years, have reported a significant reduction in the time and labor required to thin flowers. ... >>

Advanced Infrared Microscope 02.05.2024

Microscopes play an important role in scientific research, allowing scientists to delve into structures and processes invisible to the eye. However, various microscopy methods have their limitations, and among them was the limitation of resolution when using the infrared range. But the latest achievements of Japanese researchers from the University of Tokyo open up new prospects for studying the microworld. Scientists from the University of Tokyo have unveiled a new microscope that will revolutionize the capabilities of infrared microscopy. This advanced instrument allows you to see the internal structures of living bacteria with amazing clarity on the nanometer scale. Typically, mid-infrared microscopes are limited by low resolution, but the latest development from Japanese researchers overcomes these limitations. According to scientists, the developed microscope allows creating images with a resolution of up to 120 nanometers, which is 30 times higher than the resolution of traditional microscopes. ... >>

Air trap for insects 01.05.2024

Agriculture is one of the key sectors of the economy, and pest control is an integral part of this process. A team of scientists from the Indian Council of Agricultural Research-Central Potato Research Institute (ICAR-CPRI), Shimla, has come up with an innovative solution to this problem - a wind-powered insect air trap. This device addresses the shortcomings of traditional pest control methods by providing real-time insect population data. The trap is powered entirely by wind energy, making it an environmentally friendly solution that requires no power. Its unique design allows monitoring of both harmful and beneficial insects, providing a complete overview of the population in any agricultural area. “By assessing target pests at the right time, we can take necessary measures to control both pests and diseases,” says Kapil ... >>

Random news from the Archive

There is less and less oxygen in the Earth's atmosphere 09.10.2016

Geologists from Princeton University (USA), led by Assistant Professor John Higgins and Professor Michael Bender, analyzed for the first time data on the dynamics of oxygen and carbon dioxide content in the Earth's atmosphere over the past 800 thousand years, and came to the conclusion that it has been gradually declining all this time, and in the last 100 years it has begun to fall sharply.

Princeton scientists used an innovative technique based on the analysis of air bubbles from different layers of the ice caps of Greenland and Antarctica. He showed that over the past 800 thousand years, O2 in the earth's atmosphere has decreased by 0,7% compared to the current level.

By geological standards, this is a normal speed, but there is one important detail - a decrease of 0,1% has occurred in just the last 100 years. Obviously, the reason is human activity, namely the burning of fossil fuels, which absorb oxygen and release carbon dioxide into the atmosphere.

Just another interesting aspect is connected with carbon dioxide. The study showed that its global level throughout these 800 thousand years remained generally unchanged, despite the cyclical fluctuations associated with ice ages. But in recent decades, as you know, the content of CO2 in the atmosphere is growing rapidly, and has already reached a dangerous level.

What is the conclusion from this? Obviously, when the change in the composition of the atmosphere occurs so quickly, the planet does not have time to compensate for it by "packing" it into silicates.

“Earth can handle additional carbon dioxide when it has thousands or millions of years to do so. But now humanity is releasing CO2 into the atmosphere so quickly that silicate absorption mechanisms cannot keep up. Humans have made long processes on Earth very fast,” Higgins concluded.

Other interesting news:

▪ Smartphone flat camera technology

▪ Liquid nanotransistors for supercomputers

▪ Stereo can be dangerous

▪ Three types of people

▪ Liquid water found on Mars

News feed of science and technology, new electronics

 

Interesting materials of the Free Technical Library:

▪ site section Preamplifiers. Article selection

▪ Fen painter's article. Tips for the home master

▪ article What are the top ten driest cities in the world? Detailed answer

▪ article I say. Legends, cultivation, methods of application

▪ article Digital auto-adjuster of the OZ angle. Encyclopedia of radio electronics and electrical engineering

▪ article Name the map. Focus Secret

Leave your comment on this article:

Name:


Email (optional):


A comment:





All languages ​​of this page

Home page | Library | Articles | Website map | Site Reviews

www.diagram.com.ua

www.diagram.com.ua
2000-2024