EIOT UNIT 2 - Programming Embedded C
EIOT UNIT 2 - Programming Embedded C
Systems in C
⚫ An Embedded System is a system that has software
embedded into computer-hardware, which makes a
system dedicated for a variety of application or
specific part of an application or product or part of a
larger system.
An embedded system is a combination of three major components:
⚫ Hardware: Hardware is physically used component that is
physically connected with an embedded system. It comprises of
microcontroller based integrated circuit, power supply, LCD display
etc.
⚫ Application software: Application software allows the user to
perform varieties of application to be run on an embedded system by
changing the code installed in an embedded system.
⚫ Real Time Operating system (RTOS): RTOS supervises the way an
embedded system work. It act as an interface between hardware and
application software which supervises the application software and
provide mechanism to let the processor run on the basis of
scheduling for controlling the effect of latencies.
Designing of an embedded
system
Design steps required for the
development of Embedded System
Programming Embedded
Systems in C
⚫ Embedded C is an extension of the C Programming
Language, tailored for embedded systems
development, encompassing features such as I/O
hardware addressing, fixed-point arithmetic, and
memory access.
⚫
Keywords in Embedded C
⚫ bit
⚫ sbit
⚫ sfr
⚫ sfr16
⚫ small
⚫ large
Basic Structure of Embedded C
Program
Different Components of
Embedded C
Programs to Add two numbers
⚫ #include<reg51.h>
int a,b,c;
void main()
{
P0=0x10;
P1=0x15;
P2=P0+P1;
}
AND operation
⚫ #include<reg51.h>
int a,b,c;
void main()
{
P0=0x10;
P1=0x15;
P2=P0&P1;
}
#include <reg51.h>
#include <stdio.h>
int a,b,c;
void InitUart(void)
{
TMOD = 0x20; // 9600 baud rate
TH1 = 0xFD;
TI = 1;
TR1 = 1;
}
void main()
{
InitUart();
printf("\n\r Enter the First Data\t");
scanf("%d",&a);
printf("\n\r A=%d",a);
printf("\n\r Enter the Second Data\t");
scanf("%d",&b);
printf("\n\r B=%d",b);
c=a+b;
printf("\n\r Result = %d",c);
while(1);
}
Difference between C and
Embedded C