Professional Documents
Culture Documents
ON
INTRODUCTION TO EMBEDDED
SYSTEM AND
EMBEDDED C
BY :UDIT GUPTA
(1209122092)
Embedded system
Continued..
Characteristics:
What is embedded c?
Development process of
Embedded C projects
continued
Editor
Program
Embedded C
program
Simulation
and
debugging
Advantages
INTRODUCTION
FEATURES
High-performance 8 bit
Microcontroller
Up to 16 MIPS Throughput at 16 MHz
32 x 8 General Purpose Working
Registers
Six ADC channels in PDIP package
Internal Calibrated Oscillator
TYPES OF PACKAGES
MEMORY SEGMENTS
PIN OUT
PORTS
Three ports i.e PortB, PortC, PortD
Three registers associated with every port
DDRx Data Direction Register
PINx Port input
PORTx- Port output
DDRx
PORTx
Output
PORTx
PINx
Port B (PB7..PB0)
Port C (PC6..PC0)
Port D (PD7..PD0)
Coding window
Build status
FIRST
PROGRAM
BLINKING
LED
#include<avr/io.h>
#include<util/delay.h>
#define F_CPU 1000000UL
void wait(float x)
{
for(int i=0;i<(int)(x*1302);i++)
_delay_loop_1(0);
}
main()
{
DDRB=0xFF;// PORT B as output port
while(1)
{
PORTB=0b11111111;
wait(.5);
PORTB=0b00000000;
wait(.5);
}
}
LINE
FOLLOWER
ROBOT
CODING
#include <avr/io.h>
// includes input/output header file
#include <util/delay.h> // includes delay header file
int main(void)
{
DDRB=0b11111111; //PORTB as output Port connected to motors
DDRC=0b0000000; //PORTC Input port connected to Sensors
int left_sensor=0, right_sensor=0;
while(1) // infinite loop
{
left_sensor=PINC&0b0000001; // mask PC4 bit of Port C
right_sensor=PINC&0b0000010;// mask PC5 bit of Port C
if((left_sensor==0b0000000) && (right_sensor==0b0000000)) //if both sensors "off"
{ PORTB=0b00000000; // stop}
if((left_sensor==0b0000001) && (right_sensor==0b0000010)) //if both sensors "on"
{
PORTB=0b00010010; // move straight
}
if((left_sensor==0b0000000)&&(right_sensor==0b0000010))
{
PORTB=0b00000010; // turn left
}
if((left_sensor==0b0000001)&&(right_sensor==0b0000000))
{
PORTB=0b00010000; // turn right
}
}
}
THANK YOU