Blogroll

Powered by Blogger.

Sunday, 16 February 2014

How To Program ATmega Microcontrollers Using Parallel Port In Linux

by realfinetime  |  in Microcontroller at  09:15

Parallel Port Programmer for ATmega8 is a simple circuit that can be made at home. Parallel Port Programmer Circuit is as shown below. 

Circuit Diagram
Parallel port programming atmega microcontroller in ubuntu


Components Required
9V Battery                     - 1
7805 Voltage Regulator   - 1
ATmega8                       - 1
DB-25 Female                - 1
Crystal Oscillator 4MHz  - 1
Resistor 10K                  - 1
Resistor 1K                    - 8
Capacitor 27pF               - 2
Capacitor 10uf                - 1
Capacitor 1 uf                 - 1

Softwares To Be Installed

1. avr-libc
2. binutils-avr
3. avrdude
4. gcc
5. gcc-avr
6. uisp

Software Installation
Now open your terminal and execute the following commands to install the softwares.
          
sudo apt-get install avr-libc binutils-avr avrdude gcc gcc-avr
sudo apt-get install uisp

Now create your first program.

Execute the following command to create the program file.

nano first.c

Now copy the following code to this file.

#include <avr/io.h>

#include <util/delay.h>

void sleep(uint8_t millisec)

{
while(millisec)
{
_delay_ms(1);/* 1 ms delay */
millisec--;
}
}

int main()

{
DDRC |=0b11111111;   //Declare PORT C as an output
while(1)
        
{
PORTC |=0b11111111;
PORTC &=0b00000000;  //turn off PORT C 
sleep(1000);

PORTC |=0b11111111;

PORTC &=0b11111111; //turn on PORT C
sleep(1000);
  }
return 1;
}

Next is to save the file. Press CTRL + O  to save the file. Now exit from the file. Press CTRL + X to exit from the file.

Next is to compile the code. Execute the following command to compile the code. Compiling will generate an object file.

avr-gcc -mmcu=atmega8 first.c -o first

Now generate the hex file from the object file. Execute the following command to generate the hex file.

avr-objcopy -O ihex first first.hex

Now upload the hex file to your microcontroller using the following command. Before executing the following command connect the programmer circuit to your parallel port.

sudo uisp -dprog=dapa -dpart=ATmega8 if=first.hex -dlpt=0x378 --erase --upload

Now you will get the following result in terminal. Then programming ATmega8 is successfull.

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Browse the best mobile phone blogs online, know about invention of mobile phones, history, technical information, technology used, and all about phones you should know.Visit our website and Explore Now!

    Invention Of Mobile Phone

    ReplyDelete

IMPORTANT NOTICE

All the circuits, published in this blog is only after testing and getting proper results in my private lab. When you try these circuits, you should check the supply voltage, polarity of components, presence of childrens nearby and shorts in the circuits. This website will not be responsible for any harm happened to you or your components caused by your carelessness.

For More Electronic Tips



Proudly Powered by Blogger.