Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
8051 Programming
Assembly language----- includes mnemonics
Example: ADD, SUB, MUL, RR…
Assembly Language-----Assembler---Binary
Disadvant...
Higher level languages : c ,java
( c, c++,java)------compiler----binary
Advantage:
No need to consider about architectur...
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 unsign...
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: s...
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...
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...
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...
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 ...
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...
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...
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)...
LCD INITIALIZATION Using commands
0X38 =========2 lines and 5x7 matrix
0x01 ========= clear the display
0x06 ========= ...
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...
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 ...
WAP to display your name on LCD
Program6:
#include<reg51.h>
#define dataport P2 // for LCD
void delay(int a);
void lcd_cmd...
void main(void)
{
lcd_cmd(0x38); //function set
delay(50);
lcd_cmd(0x0C); //display on,cursor off,blink off
delay(50);
lcd...
Prochain SlideShare
Chargement dans…5
×

8051 basic programming

506 vues

Publié le

this ppt gives information about using 8051 pins as input and outpins , lcd module interfacing to 8051

Publié dans : Ingénierie
  • Soyez le premier à commenter

8051 basic programming

  1. 1. 8051 Programming
  2. 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. 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. 4. STEPS FOLLOWED IN CONVERTING SOURCE FILE TO HEX. FILE
  5. 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. 6. 1) BASIC PORT PROGRAMMING P0 ------- P0=____________? MSB LSB
  7. 7. BASIC PORT PROGRAMMING…………………… P0------- 8 4 2 1 8 4 2 1 ANS: P0=0X55
  8. 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. 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. 10. Syntax to be followed: port declaration: #define variablename Px Where, x=0,1,2,3 Example: #define segment P1
  11. 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++); }
  12. 12. INTRODUCTION TO KEIL IDE FOR 80XX PROGRAMMING
  13. 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. 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. 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. 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
  17. 17. 16X2 LCD Display
  18. 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. 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. 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. 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. 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. 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); }

×