NOW U DON'T NEED TO RUN TO ANY CENTER FOR LEARNIG EMBEDDED C..
BECAUSE NOW YOU CAN GET YOUR TUTORIALS SITTING HOME..:)
First of oll i will introduce you all to microcontroller (Atmega16). Try to remember the points given below,than it will be easy for you to understand.
- It is 8bits microcontroller having total 40 pins.
- We will program it using "avr stdio".
- It has EEPROM(Erasable Programmable ROM) of 512 bytes.
- It has16 Kb flash memory and 1 Kb SRAM(Static RAM).
- The clock frequency is 1 MHz which can be increased upto 16 MHz using external oscillator.
LET'S SEE THE PIN CONFIGURATION NOW..
Here, you can see we have four PORTS namely PORTA, PORTB, PORTC, AND PORTD. All these PORTS can be used as input and output PORT.
pin description
PIN(1-7) is called as PORT B
PIN(14-21) is called as PORT D.
PIN(22-29) is our PORT C and PIN(33-40) is called as ADC or PORT D.
NOW I WILL GIVE YOU A VERY SHORT DESCRIPTION OF REMAINING PINS, SO THAT YOU DONT HAVE TO GET BORED..
PIN-8 is a "serial clock".
PIN-9 is "reset pin"
PIN-10 is connected to "Vcc"(usually 5V supply).
PIN-11 is ground (*remember gnd means 0V).
PIN-12 is "input to the inverting oscillator amplifier".
PIN-13 is the o/p from the oscillator.
PIN-30 is Aref (i.e. analog reference voltage*it is used as reference voltage for ADC PORTD)
PIN-31 it is "GROUND" for PORT D
PIN-32 it is supply voltage for PORT D(*we provide separate supply ,ground for PORT D)
(Please friends try to remember function of all these PINS and than proceed further) :)
Now install AVR studio in your computer.// Compiler is Win avr and burner is avr_dude
"HEADER FILES OF AVR STUDIO"
#include<avr/io.h> /*input-output library
#include<util/delay.h> /* for providing delays(e.g _delay_ms(1000); command will give delay of 1 second
HOW TO USE OUR PORTS
1.If we use DDR in our command than this means we can use our PORT for data inflow/outflow.
2.PORT is used to take output from microcontroller.
3.PIN is used to give any input to the microcontroller. /* don't worry if you didn't understand it properly, i will make you unerstand by a very simple program*/
First program to turn "LEDS ON/OFF"
#include<avr/io.h>
#include<util/delay.h>
void main()
{
DDRB=0b11111111; // i have selected PORT D by setting all 8 pins to 1//
while(1) //infinite loop,so that led's keep running on/off//
{
PORTB=0b00000000; // i have set all pins to '0' by doing this all my leds will turn off//
_delay_ms(1000);
PORTB=0b11111111; // i have set all pins to '1' by doing this i am giving command to turn led on//
_delay_ms(1000);
}
} //now compile and run this program in your development board//
THINGS TO KEEP IN MIND...:) always write PORT,PIN,DDR in capital and rest in small letter.. ;)
similarly, you can make programs for running led's, diverging led's, converging led's, sandwatch etc. please try them by yourself.. :)
FRIENDS, NOW I WILL TELL YOU ABOUT SEVEN SEGMENT DISPLAY LCD..
#here is the pin diagram..(later i will give some links where you can get valuable information :) )
# You all must have seen 7 segment display in your digital watches, calculators,at railway stations and airports etc..
# A single display has seven segments(you can consider a segment as a line)+ a decimal point(dp).
# It has two configurations namely "common anode" and "common cathode".
# If you look at the pin configuration of 7 segment,you will find it has ten pins. The pins 1 and 2 are shorted.
# In common anode config. 5V is given to 1 and 2, while in common anode config. 0V is given to both of them.
NOW LET'S MOVE TO a very simple PROGRAM of DISPLAYING NUMBERS ON 7 SEG. LCD
#include<avr/io.h>
#include<util/delay.h>
void main()
{
DDRC=0xff;
while(1)
{
PORTC=0b00111111; // it will display 0 on screen//
_delay_ms(500);
PORTC=0b; // it will display 1 on screen//
_delay_ms(500);
PORTC=0b01100000;;
_delay_ms(500);
PORTC=0b11011010;
_delay_ms(500);
PORTC=0b11110010;
_delay_ms(500);
PORTC=0b01100110;
_delay_ms(500);
PORTC=0b10110110;
_delay_ms(500);
PORTC=0b10111110;
_delay_ms(500);
PORTC=0b11100000;
_delay_ms(500);
PORTC=0b11111110;
_delay_ms(500);
PORTC=0b11100110;
_delay_ms(500);
}
}
friends waiting for ur feedback..

