0% found this document useful (0 votes)
6 views24 pages

EMBEDDED C & Working With AVR Studio

PPT ON EMBEDDED C

Uploaded by

Karan Verma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views24 pages

EMBEDDED C & Working With AVR Studio

PPT ON EMBEDDED C

Uploaded by

Karan Verma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 24

Introduction of Embedded C and demo programs

• Development process of AVR projects


• Control structures in C
• Algorithms to be studied
• AVR studio
Embedded system
• An Embedded system is combination of
computer hardware and software, and
perhaps additional mechanical or others parts,
designed to perform a specific task.
• Example:
microwave oven, AC etc
What is Embedded C?
• Embedded C is nothing but a subset of C language which is
compatible with certain microcontrollers.
• Some features are added using header files like <avr/io.h>,
<util/delay.h>.
• scanf() and printf() are removed as the inputs are scanned
from the sensors and outputs are given to the ports.
• Control structures remain the same like if-statement, for
loop, do-while etc.
Development process of Embedded C projects
• Write C programs in AVR Studio.
• Compile them into a .hex file using the AVR-GCC compiler
(which integrates into AVR Studio).
• Simulate the target AVR program and debug the code within
AVR Studio.
• Program the actual chip using the AVRISP mkII USB device,
which is attached to our target board with a special 6-pin cable.
• Once programmed, the chip runs the program in your circuit.
If-statement
• Syntax:
if( condition)
{
statement…….
}
else
{
statement……..
}
Program for if-statement
Int a=4;
Int b=5;
If(a>b)
printf(“ a is largest”);
else
printf(“ b is largest”);
Do- while statement
• Syntax:
Initial counter
Do
{
statement…….
update statement
}
While(condition);
Program for do-while
Int a=4;
Do
{
a++;
}
while(a>5);
For- statement
• Syntax:
For( initial counter; test condition; update stmt)
{
statement……..
statement……...
}
• Program:
for(int i=0;i<5;i++)
sprintf(str, “Hello”);
1. Blinking LED
Program:
main()
{
DDRB=0XFF;
while(1)
{
PORTB=0XFF;
_delay_ms(255);
PORTB=0X00;
_delay_ms(255);
}
Creation of AVR Projects with AVR
studio
Home screen of AVR STUDIO
Naming project as Line follower
Selecting Platform and Device
Coding window
Building the code
Build and Run the code
How to burn the .hex file in MCU
Select the HIDBootFlash AVR Programmer icon
Click on to the find device.
Now Click On Open .hex File & browse it
Browse the file from your project folder , select
the hex file and click open.
Check out Reboot AVR & Flash Device
THANK YOU…

You might also like