SlideShare a Scribd company logo
8051 Programming
Assembly language----- includes mnemonics
Example: ADD, SUB, MUL, RR…
Assembly Language-----Assembler---Binary
Disadvantage:
We should know about architecture of microcontroller or
microcontroller
Higher level languages : c ,java
( c, c++,java)------compiler----binary
Advantage:
No need to consider about architecture of µp/µc….just
few features are considered
STEPS FOLLOWED IN CONVERTING SOURCE FILE TO HEX. FILE
EMBEDDED C
DATA TYPES USED IN EMBEDDED C
Integer int x;
Unsigned integer unsigned int x;
Char char x;
Unsigned char unsigned char x;
1) BASIC PORT PROGRAMMING
P0 -------
P0=____________?
MSB LSB
BASIC PORT PROGRAMMING……………………
P0-------
8 4 2 1 8 4 2 1
ANS: P0=0X55
Syntax to be followed:
Pin declaration:
sbit variablename = PX ^Y;
Where,
x=0,1,2,3 port
y=0,1,2,3,4,5,6,7 pins
Example: sbit led = P1^0;
WAP to blink a led which is connected to port2 , pin 0
#include<reg52.h>
sbit led = P2^0;
unsigned int i;
void main()
{
P2=0x00;
led =1;
for(i=0; i<1000; i++);
led =0;
for(i=0; i<1000; i++);
}
Syntax to be followed:
port declaration:
#define variablename Px
Where,
x=0,1,2,3
Example: #define segment P1
WAP to blink all led’s connected to port2
#include<reg52.h>
#define leds P2
unsigned int i;
void main()
{
leds=0x00;
for(i=0; i<1000; i++);
leds =0xFF;
for(i=0; i<1000; i++);
}
INTRODUCTION
TO
KEIL IDE
FOR
80XX PROGRAMMING
PROGRAM 1:
WAP to blink a led which is connected to port1 , pin 0
PROGRAM 2:
WAP to blink the led’s which are connected to port1
PROGRAM 3:
WAP to blink the led’s alternatively which are
connected to port1
Practice examples
pin7 pin6 pin5 pin4 pin3 pin2 pin1 pin0
0 0 0 0 0 0 0 1
0 0 0 0 0 0 1 0
0 0 0 0 0 1 0 0
0 0 0 0 1 0 0 0
0 0 0 1 0 0 0 0
0 0 1 0 0 0 0 0
0 1 0 0 0 0 0 0
1 0 0 0 0 0 0 0
PROGRAM 4:
WAP to shift a bit of port1 from pin0 to pin7
PROGRAM 5:
WAP to shift a bit of port1 from pin7 to pin0
Pin7 pin6 pin5 pin4 pin3 pin2 pin1 pin0
1 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0
0 0 1 0 0 0 0 0
0 0 0 1 0 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 0 1 0 0
0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 1
PROGRAM 6:
WAP to shift a bit of port1 from pin0 to pin7
pin7 pin6 pin5 pin4 pin3 pin2 pin1 pin0
0 0 0 0 0 0 0 1
0 0 0 0 0 0 1 1
0 0 0 0 0 1 1 1
0 0 0 0 1 1 1 1
0 0 0 1 1 1 1 1
0 0 1 1 1 1 1 1
0 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
16X2 LCD Display
 8 data pins
3 control pins
supply pins and a potentiometer
1. Two modes
-----Command mode (RS=0)
-----Data mode (RS=1)
2. RW is always logic zero
3. EN=1 to EN=0 for data transfer
LCD INITIALIZATION Using commands
0X38 =========2 lines and 5x7 matrix
0x01 ========= clear the display
0x06 ========= shift cursor to right i.e. increment cursor
0x05 ========= shift display right
0x0E ========= display on, cursor blinking
0x80 ========= force cursor to beginning of first line
0xC0 ========= force cursor to beginning of first line
To pass command to lcd
8datapins = data
RS=0
RW=0
EN=1
Delay()
EN=0
To pass command to lcd
8datapins = data
RS=1
RW=0
EN=1
Delay()
EN=0
void lcd_cmd(unsigned char d)
{
dataport =d;
rs= 0;
rw=0;
e=1;
delay(150);
e=0;
delay(150);
}
void lcd_data(unsigned char f)
{
dataport =f;
rs= 1;
rw=0;
e=1;
delay(150);
e=0;
delay(150);
}
Sample code:
WAP to display your name on LCD
Program6:
#include<reg51.h>
#define dataport P2 // for LCD
void delay(int a);
void lcd_cmd(unsigned char d);
void lcd_data(unsigned char f);
sbit rs =P1^0; // rs pin of LCD
sbit rw =P1^2; // rw pin of LCD
sbit e = P1^1; // enable pin of LCD
void delay(int a)
{
int i;
for(i=0;i<a;i++);
}
void main(void)
{
lcd_cmd(0x38); //function set
delay(50);
lcd_cmd(0x0C); //display on,cursor off,blink off
delay(50);
lcd_cmd(0x80); //first row
delay(50);
lcd_cmd(0x06); //entry mode, set increment
delay(50);
lcd_cmd(0x80); //first row
delay(10);
dataport=0;
P1=0X00;
lcd_data('E');
delay(10);
lcd_data('C');
delay(10);
lcd_data('E');
delay(1500);
}

More Related Content

What's hot

1.ppi 8255
1.ppi 8255 1.ppi 8255
1.ppi 8255
MdFazleRabbi18
 
Flip flops, counters &amp; registers
Flip flops, counters &amp; registersFlip flops, counters &amp; registers
Flip flops, counters &amp; registers
Dharit Unadkat
 
Counters
CountersCounters
Counters
Ketaki_Pattani
 
Digital electronics logic families
Digital electronics logic familiesDigital electronics logic families
Digital electronics logic families
BLESSINAR0
 
Unit 4 sequential circuits
Unit 4  sequential circuitsUnit 4  sequential circuits
Unit 4 sequential circuits
AmrutaMehata
 
Counters
CountersCounters
Counters
Randaqra
 
Data Flow Modeling
Data Flow ModelingData Flow Modeling
Data Flow Modeling
Padmanaban Kalyanaraman
 
PAL And PLA ROM
PAL And PLA ROMPAL And PLA ROM
PAL And PLA ROM
RONAK SUTARIYA
 
Introduction state machine
Introduction state machineIntroduction state machine
Introduction state machine
Shreyans Pathak
 
RH CRITERIA
RH CRITERIARH CRITERIA
RH CRITERIA
ramola007
 
Programmable logic array
Programmable logic arrayProgrammable logic array
Programmable logic array
Huba Akhtar
 
decade counter
decade counterdecade counter
decade counter
Abhishek Sainkar
 
Logic simplification sop and pos forms
Logic simplification sop and pos formsLogic simplification sop and pos forms
Logic simplification sop and pos forms
Manesh T
 
Time domain analysis
Time domain analysisTime domain analysis
Time domain analysis
Mohammed Waris Senan
 
Embedded c program and programming structure for beginners
Embedded c program and programming structure for beginnersEmbedded c program and programming structure for beginners
Embedded c program and programming structure for beginners
Kamesh Mtec
 
Serial Communication in 8051
Serial Communication in 8051Serial Communication in 8051
Serial Communication in 8051
Sudhanshu Janwadkar
 
Tuned amplifiers
Tuned amplifiersTuned amplifiers
Tuned amplifiers
herald Rufus
 
flip flops
flip flops flip flops
flip flops
Unsa Shakir
 
Logical and shift micro operations
Logical and shift micro operationsLogical and shift micro operations
Logical and shift micro operations
Sanjeev Patel
 
J - K & MASTERSLAVE FLIPFLOPS
J - K & MASTERSLAVE FLIPFLOPSJ - K & MASTERSLAVE FLIPFLOPS
J - K & MASTERSLAVE FLIPFLOPS
Krishma Parekh
 

What's hot (20)

1.ppi 8255
1.ppi 8255 1.ppi 8255
1.ppi 8255
 
Flip flops, counters &amp; registers
Flip flops, counters &amp; registersFlip flops, counters &amp; registers
Flip flops, counters &amp; registers
 
Counters
CountersCounters
Counters
 
Digital electronics logic families
Digital electronics logic familiesDigital electronics logic families
Digital electronics logic families
 
Unit 4 sequential circuits
Unit 4  sequential circuitsUnit 4  sequential circuits
Unit 4 sequential circuits
 
Counters
CountersCounters
Counters
 
Data Flow Modeling
Data Flow ModelingData Flow Modeling
Data Flow Modeling
 
PAL And PLA ROM
PAL And PLA ROMPAL And PLA ROM
PAL And PLA ROM
 
Introduction state machine
Introduction state machineIntroduction state machine
Introduction state machine
 
RH CRITERIA
RH CRITERIARH CRITERIA
RH CRITERIA
 
Programmable logic array
Programmable logic arrayProgrammable logic array
Programmable logic array
 
decade counter
decade counterdecade counter
decade counter
 
Logic simplification sop and pos forms
Logic simplification sop and pos formsLogic simplification sop and pos forms
Logic simplification sop and pos forms
 
Time domain analysis
Time domain analysisTime domain analysis
Time domain analysis
 
Embedded c program and programming structure for beginners
Embedded c program and programming structure for beginnersEmbedded c program and programming structure for beginners
Embedded c program and programming structure for beginners
 
Serial Communication in 8051
Serial Communication in 8051Serial Communication in 8051
Serial Communication in 8051
 
Tuned amplifiers
Tuned amplifiersTuned amplifiers
Tuned amplifiers
 
flip flops
flip flops flip flops
flip flops
 
Logical and shift micro operations
Logical and shift micro operationsLogical and shift micro operations
Logical and shift micro operations
 
J - K & MASTERSLAVE FLIPFLOPS
J - K & MASTERSLAVE FLIPFLOPSJ - K & MASTERSLAVE FLIPFLOPS
J - K & MASTERSLAVE FLIPFLOPS
 

Similar to 8051 basic programming

PIC16F877A interfacing with LCD
PIC16F877A interfacing with LCDPIC16F877A interfacing with LCD
PIC16F877A interfacing with LCD
sunil polo
 
W10: Interrupts
W10: InterruptsW10: Interrupts
W10: Interrupts
Daniel Roggen
 
Micro controller(pratheesh)
Micro controller(pratheesh)Micro controller(pratheesh)
Micro controller(pratheesh)
Pratheesh Pala
 
Micro c lab6(lcd)
Micro c lab6(lcd)Micro c lab6(lcd)
Micro c lab6(lcd)
Mashood
 
Buy Embedded Systems Projects Online,Buy B tech Projects Online
Buy Embedded Systems Projects Online,Buy B tech Projects OnlineBuy Embedded Systems Projects Online,Buy B tech Projects Online
Buy Embedded Systems Projects Online,Buy B tech Projects Online
Technogroovy
 
Applications of microcontroller(8051)
Applications of microcontroller(8051) Applications of microcontroller(8051)
Applications of microcontroller(8051)
vijaydeepakg
 
PIC introduction + mapping
PIC introduction + mappingPIC introduction + mapping
PIC introduction + mapping
OsaMa Hasan
 
LCD_Example.pptx
LCD_Example.pptxLCD_Example.pptx
LCD_Example.pptx
julioalexanderaguila
 
Microcontroller
MicrocontrollerMicrocontroller
Microcontroller
Spitiq
 
Moving message display
Moving message displayMoving message display
Moving message display
viraj1989
 
Customizable Microprocessor design on Nexys 3 Spartan FPGA Board
Customizable Microprocessor design on Nexys 3 Spartan FPGA BoardCustomizable Microprocessor design on Nexys 3 Spartan FPGA Board
Customizable Microprocessor design on Nexys 3 Spartan FPGA Board
Bharat Biyani
 
Mpi lab manual eee
Mpi lab manual eeeMpi lab manual eee
Mpi lab manual eee
Vivek Kumar Sinha
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
karthiga selvaraju
 
Assembler4
Assembler4Assembler4
Assembler4
Omar Sanchez
 
Https _doc-0o-c4-apps-viewer.googleusercontent
Https  _doc-0o-c4-apps-viewer.googleusercontent Https  _doc-0o-c4-apps-viewer.googleusercontent
Https _doc-0o-c4-apps-viewer.googleusercontent
vijaydeepakg
 
Programming the Basic Computer and Assembler
Programming the Basic Computer and AssemblerProgramming the Basic Computer and Assembler
Programming the Basic Computer and Assembler
Mitul Patel
 
Microcontroller part 4
Microcontroller part 4Microcontroller part 4
Microcontroller part 4
Keroles karam khalil
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051
Sadiq Rahim
 
Microcontroller 8051- soft.ppt
Microcontroller 8051- soft.pptMicrocontroller 8051- soft.ppt
Microcontroller 8051- soft.ppt
steffydean
 
Lcd interfacing
Lcd interfacingLcd interfacing
Lcd interfacing
AshuKaranam
 

Similar to 8051 basic programming (20)

PIC16F877A interfacing with LCD
PIC16F877A interfacing with LCDPIC16F877A interfacing with LCD
PIC16F877A interfacing with LCD
 
W10: Interrupts
W10: InterruptsW10: Interrupts
W10: Interrupts
 
Micro controller(pratheesh)
Micro controller(pratheesh)Micro controller(pratheesh)
Micro controller(pratheesh)
 
Micro c lab6(lcd)
Micro c lab6(lcd)Micro c lab6(lcd)
Micro c lab6(lcd)
 
Buy Embedded Systems Projects Online,Buy B tech Projects Online
Buy Embedded Systems Projects Online,Buy B tech Projects OnlineBuy Embedded Systems Projects Online,Buy B tech Projects Online
Buy Embedded Systems Projects Online,Buy B tech Projects Online
 
Applications of microcontroller(8051)
Applications of microcontroller(8051) Applications of microcontroller(8051)
Applications of microcontroller(8051)
 
PIC introduction + mapping
PIC introduction + mappingPIC introduction + mapping
PIC introduction + mapping
 
LCD_Example.pptx
LCD_Example.pptxLCD_Example.pptx
LCD_Example.pptx
 
Microcontroller
MicrocontrollerMicrocontroller
Microcontroller
 
Moving message display
Moving message displayMoving message display
Moving message display
 
Customizable Microprocessor design on Nexys 3 Spartan FPGA Board
Customizable Microprocessor design on Nexys 3 Spartan FPGA BoardCustomizable Microprocessor design on Nexys 3 Spartan FPGA Board
Customizable Microprocessor design on Nexys 3 Spartan FPGA Board
 
Mpi lab manual eee
Mpi lab manual eeeMpi lab manual eee
Mpi lab manual eee
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
 
Assembler4
Assembler4Assembler4
Assembler4
 
Https _doc-0o-c4-apps-viewer.googleusercontent
Https  _doc-0o-c4-apps-viewer.googleusercontent Https  _doc-0o-c4-apps-viewer.googleusercontent
Https _doc-0o-c4-apps-viewer.googleusercontent
 
Programming the Basic Computer and Assembler
Programming the Basic Computer and AssemblerProgramming the Basic Computer and Assembler
Programming the Basic Computer and Assembler
 
Microcontroller part 4
Microcontroller part 4Microcontroller part 4
Microcontroller part 4
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051
 
Microcontroller 8051- soft.ppt
Microcontroller 8051- soft.pptMicrocontroller 8051- soft.ppt
Microcontroller 8051- soft.ppt
 
Lcd interfacing
Lcd interfacingLcd interfacing
Lcd interfacing
 

Recently uploaded

New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
wisnuprabawa3
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt
PuktoonEngr
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
JamalHussainArman
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
drwaing
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
rpskprasana
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
ssuser36d3051
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
kandramariana6
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
yokeleetan1
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
Divyam548318
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
Dr Ramhari Poudyal
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
RadiNasr
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
gerogepatton
 

Recently uploaded (20)

New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt2. Operations Strategy in a Global Environment.ppt
2. Operations Strategy in a Global Environment.ppt
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 

8051 basic programming

  • 2. Assembly language----- includes mnemonics Example: ADD, SUB, MUL, RR… Assembly Language-----Assembler---Binary Disadvantage: We should know about architecture of microcontroller or microcontroller
  • 3. Higher level languages : c ,java ( c, c++,java)------compiler----binary Advantage: No need to consider about architecture of µp/µc….just few features are considered
  • 4. STEPS FOLLOWED IN CONVERTING SOURCE FILE TO HEX. FILE
  • 5. EMBEDDED C DATA TYPES USED IN EMBEDDED C Integer int x; Unsigned integer unsigned int x; Char char x; Unsigned char unsigned char x;
  • 6. 1) BASIC PORT PROGRAMMING P0 ------- P0=____________? MSB LSB
  • 8. Syntax to be followed: Pin declaration: sbit variablename = PX ^Y; Where, x=0,1,2,3 port y=0,1,2,3,4,5,6,7 pins Example: sbit led = P1^0;
  • 9. WAP to blink a led which is connected to port2 , pin 0 #include<reg52.h> sbit led = P2^0; unsigned int i; void main() { P2=0x00; led =1; for(i=0; i<1000; i++); led =0; for(i=0; i<1000; i++); }
  • 10. Syntax to be followed: port declaration: #define variablename Px Where, x=0,1,2,3 Example: #define segment P1
  • 11. WAP to blink all led’s connected to port2 #include<reg52.h> #define leds P2 unsigned int i; void main() { leds=0x00; for(i=0; i<1000; i++); leds =0xFF; for(i=0; i<1000; i++); }
  • 13. PROGRAM 1: WAP to blink a led which is connected to port1 , pin 0 PROGRAM 2: WAP to blink the led’s which are connected to port1 PROGRAM 3: WAP to blink the led’s alternatively which are connected to port1 Practice examples
  • 14. pin7 pin6 pin5 pin4 pin3 pin2 pin1 pin0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 PROGRAM 4: WAP to shift a bit of port1 from pin0 to pin7
  • 15. PROGRAM 5: WAP to shift a bit of port1 from pin7 to pin0 Pin7 pin6 pin5 pin4 pin3 pin2 pin1 pin0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1
  • 16. PROGRAM 6: WAP to shift a bit of port1 from pin0 to pin7 pin7 pin6 pin5 pin4 pin3 pin2 pin1 pin0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 1 1 1 0 0 0 0 1 1 1 1 0 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
  • 18.  8 data pins 3 control pins supply pins and a potentiometer 1. Two modes -----Command mode (RS=0) -----Data mode (RS=1) 2. RW is always logic zero 3. EN=1 to EN=0 for data transfer
  • 19. LCD INITIALIZATION Using commands 0X38 =========2 lines and 5x7 matrix 0x01 ========= clear the display 0x06 ========= shift cursor to right i.e. increment cursor 0x05 ========= shift display right 0x0E ========= display on, cursor blinking 0x80 ========= force cursor to beginning of first line 0xC0 ========= force cursor to beginning of first line
  • 20. To pass command to lcd 8datapins = data RS=0 RW=0 EN=1 Delay() EN=0 To pass command to lcd 8datapins = data RS=1 RW=0 EN=1 Delay() EN=0
  • 21. void lcd_cmd(unsigned char d) { dataport =d; rs= 0; rw=0; e=1; delay(150); e=0; delay(150); } void lcd_data(unsigned char f) { dataport =f; rs= 1; rw=0; e=1; delay(150); e=0; delay(150); } Sample code:
  • 22. WAP to display your name on LCD Program6: #include<reg51.h> #define dataport P2 // for LCD void delay(int a); void lcd_cmd(unsigned char d); void lcd_data(unsigned char f); sbit rs =P1^0; // rs pin of LCD sbit rw =P1^2; // rw pin of LCD sbit e = P1^1; // enable pin of LCD void delay(int a) { int i; for(i=0;i<a;i++); }
  • 23. void main(void) { lcd_cmd(0x38); //function set delay(50); lcd_cmd(0x0C); //display on,cursor off,blink off delay(50); lcd_cmd(0x80); //first row delay(50); lcd_cmd(0x06); //entry mode, set increment delay(50); lcd_cmd(0x80); //first row delay(10); dataport=0; P1=0X00; lcd_data('E'); delay(10); lcd_data('C'); delay(10); lcd_data('E'); delay(1500); }