Microcontrollers Laboratory
-
Upload
jabez-winston -
Category
Documents
-
view
224 -
download
0
Transcript of Microcontrollers Laboratory
-
7/25/2019 Microcontrollers Laboratory
1/38
1. INTRODUCTION TO KEIL VISION IDE
Keil Vision IDE is a window-based software development platform for 8051 and ARM
microcontrollers that combines a robust and modern editor with a project manager and make facilitytool. It integrates all the tools needed to develop embedded applications including a C/C++ compiler,
macro assembler, linker/locator, and a HEX file generator.
Vision GUI
The Vision GUI provides menus for selecting commands and toolbars with command buttons. The
Status Bar, at the bottom of the window, displays information and messages about the current
Vision command. Windows can be relocated and docked to another physical screen. The window
layout is saved for each project automatically and restored the next time the project is used. You canrestore the default layout using the menu Window Reset View to Defaults.
Vision has two operating modes, the Build Mode for creating applications and the Debug Mode for
analyzing applications, which offers additional Windows and Dialogs.
Debug Windows and Dialogs
Vision provides many debugging windows and dialogs. Some of them are
Breakpoints- Define stop conditions for program execution.
Code Coverage- Examine statistics about code execution, including branch testing.
Command Window- Enter and view executed commands.
Disassembly Window- Test programs at the level of assembly instructions.
Logic Analyzer - Investigate value changes of peripherals, registers, and variables on a time
graph.
Memory Map- Evaluate memory areas and their access rights.
Memory Window - Analyze and modify memory content.
Performance Analyzer - Evaluate time and call statistics on module or function level.
Registers Window- view and modify register content.
Serial Window is a communication interface between the application and the PC.
Status Bar - View debugging status information. Symbols Window- Find debug symbol information used in program.
System Viewer Find peripheral register information and change property values at runtime.
Toolbox Use and define configurable buttons for executing debugging commands
interactively.
Ex. No. 1
07-09-2015
-
7/25/2019 Microcontrollers Laboratory
2/38
Introduction to Keil Vision IDE
F
ig1.1:KeilIDEshowingthevariou
sWindowsavailable
-
7/25/2019 Microcontrollers Laboratory
3/38
Introduction to Keil Vision IDE
Working with Keil Vision IDE
Getting started
1.OpenKeil Vision ,Click Project New Vision Project.
2.Type a name and save the project file
Fig.1.3
Fig.1.2:Creation of new project
-
7/25/2019 Microcontrollers Laboratory
4/38
Introduction to Keil Vision IDE
3.Select Device for target as AT89S51as shown in Fig. 1.4
Fig.1.4
4.Right click Source Group 1 and select Add new Item to Source Group 1
Fig.1.5
-
7/25/2019 Microcontrollers Laboratory
5/38
In
Choose file type as ASM ,name the fil
Fig. 1.
5.Type the code ,press F7/Bulid icon
In Debug mode various simulations c
Analyzer,etc.,Register and Memory s
troduction to Keil Vision IDE
le and click Add
.6
and Ctrl+F5 / Debug icon
Fig.1. 7
an be done with variety of tools like Logic Analyz
tatus can be viewed during execution.
er, Performance
-
7/25/2019 Microcontrollers Laboratory
6/38
Introduction to Keil Vision IDE
Logic Analyzer
To perform Logic Analysis,Click View Analysis WindowLogic Analyzer as shown in Fig 1.8
Fig. 1.8
The Logic Analyzer Window opens up.Click Setup and configure as shown below to observe waveform at P1.0
Fig. 9: Logic Analyzer Setup
-
7/25/2019 Microcontrollers Laboratory
7/38
In
Output waveform will be displayed a
Performance Analyzer
To perform analysis of variou
Analyzer
Click Setup and configure as
Fig. 1.11: Setup Performa
Output of performance is sh
are shown to pave way for o
troduction to Keil Vision IDE
s
Fig. 1.10: Logic Analyzer
s parts of the program,Click View Analysis W
follows
nce Analyzer
wn. Average execution time of a function and v
timization
Fig. 1.12: Performance Analyzer
indowPerformance
arious other parameters
-
7/25/2019 Microcontrollers Laboratory
8/38
In
Register Window
Memory Window
To access Memory Window,
We can view both code mem
Code memory contains the o
To access code memory or d
Eg: C:0x00 D:0x00
Fig. 1.14 : Memory Window showi
To access Register Window
Register Window .
Register window displays t
Accumulator A ,register B,re
to R7,Program Status W
Pointer(DPTR),Stack Point
counter(PC),etc.,This ma
debugging easier
troduction to Keil Vision IDE
Click View Memory Window Memory 1
ory as well as data memory.
pcodes.Data memory contains the contents of R
ta memory,use C: or D: followed by address.
g Code Memory
,Click View
he contents of
gisters from R0
ord(PSW),Data
er(SP),Program
es program
Fig. 1 .13 : Regi
Fig. 1.15 : Memory Windo
AM.
ter Window
showing Data Memory
-
7/25/2019 Microcontrollers Laboratory
9/38
In
Disassembly Window
Click View Disassembly
Disassembly Window shows
Fig. 1.
Serial Window
Click View Serial Windows
This is useful for simulating S
Fig. 1.17 : Seria
Breakpoints
Program can be made to sto
registers at that point.
To insert a breakpoint place
remove the breakpoint.
Multiple breakpoints can be i
troduction to Keil Vision IDE
indow.
the opcodes for each instruction.
.16: Disassembly Window
UART #1
erial communication before downloading it to
l Window
at a particular instruction so as to know the sta
on a particular line or instruction and press F9.P
inserted and program will stop at breakpoints w
icrocontroller.
tus of memory and
ressing F9 again will
en run.
-
7/25/2019 Microcontrollers Laboratory
10/38
Introduction to Keil Vision IDE
Fig. 1.18 Program having breakpoints at Line 4,11 and 13
Generating HEX file
To download the compiled program into the 8051 ,HEX file needs to be generated.To generate HEX
file ,click Flash Configure Flash Tools
Fig. 1.19
A dialog box opens up.Click the Output tab and check in Create HEX fileoption.ClickOK.
Fig.1.20
-
7/25/2019 Microcontrollers Laboratory
11/38
In
Press F7/Bulid icon . Generated
Fig. 1.21 : HEX f
Fig.1. 22:Conte
Writing a sample program for blinki
Additional software required: DLL f
ALGORITHM:
1. Start
2. Load 0xFF to Port 1.
3. Call Delay routine.
4. Load 0x00 to Port 0.
5. Call Delay routine.
6. Goto Start
troduction to Keil Vision IDE
HEX file can be found in the Objects folder
ile in Objects folder
nts of the HEX file
g 8 LEDs connected to PORT 1 of 8051 periodic
iles for LED simulation ( LED_CONTROL.DLL and
ally in Keil Vision IDE.
LED_DATABASE.CDB )
-
7/25/2019 Microcontrollers Laboratory
12/38
Introduction to Keil Vision IDE
PROGRAM:
ORG 0x0000
START:MOV P1,#0xFFACALL DELAY
MOV P1,#0x00
ACALL DELAY
AJMP START
DELAY:MOV R0,#0xFF
L2:MOV R1,#0xFF
L1:DJNZ R1,L1
DJNZ R0,L2
RET
SIMULATION:
Create a new project , add a new assembly file, type the above code and save it.
To simulate the blink LED program, we have to download DLL for LED control from Keil website.
Copy the LED_CONTROL.DLL and LED_DATABASE.CDB file to Keil\C51\BIN directory.
Add this line to [C51] section of Tools.ini in Keil directory.
AGSI2=LED_CONTROL.DLL ("LED simulation")
Restart Keil Vision IDE.
With the project open, press Ctrl+F5 to Enter debug mode.
Click Peripherals LED. The LED Window opens up.
Right Click and select add LED.New LED window opens up as shown in Fig. 1.23
Fig. 1.23
-
7/25/2019 Microcontrollers Laboratory
13/38
In
Setup the pins for LED as sho
Similarly do the same for P1.
Press F5 to run the program.
RESULT:
Thus the development, debugging fe
LED was executed.
troduction to Keil Vision IDE
wn in Fig 1.24
Fig. 1.24
1 ,P1.2,.P1.7
Fig. 1.25
atures of Keil Vision IDE were studied and a sa
ple program for blinking
-
7/25/2019 Microcontrollers Laboratory
14/38
ASSEMBLY LANGUAGE PROGRAMMING IN 8051
A.Timers /Counters
AIM:
i. To operate the timer0 in mode 0 and generate square wave of 66 % duty cycle.
ii. To operate the timer1 in mode 2 and generate a delay of 100 s.
iii. Count clock pulses on P3.4 (T0 pin) and put it on Port 2
PROGRAM:
i. For generating square wave of 66 % duty cyle using timer 0 in mode 0
L1:
SETB P1.5
ACALL DELAY1
CLR P1.5
ACALL DELAY2
SJMP L1
DELAY1:
MOV TH0,#0x00 ;8 bit TH0 value
MOV TL0,#0x00 ;5 bit TL0 value
SETB TR0 ;Start timer
L2: JNB TF0,L2 ;Poll TF0 flag
CLR TR0
CLR TF0
RET
DELAY2:
MOV TH0,#0x80 ;8 bit TH0 value
MOV TL0,#0x00 ;5 bit TL0 value
SETB TR0 ;Start timer
L3: JNB TF0,L3 ;Poll TF0 flag
CLR TR0
CLR TF0
RET
OUTPUT:
Figure 2.2 Waveform at P1.5
Ex No.2
10-10-2015
-
7/25/2019 Microcontrollers Laboratory
15/38
ASSEMBLY LANGUAGE PROGRAMMING IN 8051
ii. To operate the timer1 in mode 2 and generate a delay of 100 s.
PROGRAM:
MOV TMOD,#0x20 ;Timer 1 in 8 bit autoreload mode (mode 2)
MOV TH1,#-92 ;100 s /1.085 s = 92 , 11.0592MHz ==> 1.085 s
LOOP:SETB P1.2
ACALL DELAY
CLR P1.2
ACALL DELAY
SJMP LOOP
DELAY:SETB TR1 ;Start timer 1
L1:JNB TF1,L1 ; Poll TF1 flagCLR TF1
CLR TR1
RET
OUTPUT:
Figure 2.3 Timer 1 registers
-
7/25/2019 Microcontrollers Laboratory
16/38
ASSEMBLY LANGUAGE PROGRAMMING IN 8051
Figure 2.4 Waveform at P1.2
iii. Count clock pulses on P3.5 (T0 pin) and put it on Port 2
PROGRAM:
MOV TMOD,#0x50 ; Counter 1 ,8 bit mode
MOV TH1,#0x00 ; Autoreload value
SETB P3.5
AGAIN:SETB TR1
BACK:MOV A,TL1
MOV P2,A
JNB TF1,BACK
CLR TR1
CLR TF1SJMP AGAIN
OUTPUT:
Figure 2.5
-
7/25/2019 Microcontrollers Laboratory
17/38
ASSEMBLY LANGUAGE PROGRAMMING IN 8051
B.Serial CommunicationAIM:
To turn on and turn off LEDs connected at PORT 1 by using serial communication. If y is sent LEDs are turned on
and if n is sent LEDs are turned off.Acknowledgment messages are also end.
PROGRAM:ORG 0x00
MOV TMOD,#0x20 ; Timer 1, 8 bit autoreload
MOV SCON,#0x50 ; 8 bit,1 stop bit,Receive enabled
MOV TH1,#-3 ; 9600 baud rate for 11.0592 MHz
SETB TR1
WAIT:JNB RI,WAIT ;Poll RI flag bit
MOV R0,SBUF
CLR RI
CJNE R0,#'y',C1 ;If y turn on LED
MOV P1,#0x00
SJMP DISPLAY_ON
C1:CJNE R0,#'n',C2 ;If n turn off LED
MOV P1,#0xFF
SJMP DISPLAY_OFF
C2:SJMP WAIT
STRING1:DB "LEDs ON",10,0
STRING2:DB "LEDs OFF",10,0
DISPLAY_ON:MOV DPTR,#STRING1
SJMP SEND
DISPLAY_OFF:MOV DPTR,#STRING2
SJMP SEND
SEND:CLR A
MOVC A,@A+DPTR
JZ WAIT
MOV SBUF,A ;Place character to be transmitted in SBUF
WT:JNB TI,WT ;Poll TI flag bit
CLR TI
INC DPTR
SJMP SEND
-
7/25/2019 Microcontrollers Laboratory
18/38
ASSEMBLY LANGUAGE PROGRAMMING IN 8051
OUTPUT:
Figure 2.6 (a) Serial Communication
Figure 2.6 (b) Serial Communication
-
7/25/2019 Microcontrollers Laboratory
19/38
ASSEMBLY LANGUAGE PROGRAMMING IN 8051
C.Interrupts
AIM:
To write a program for demonstrating external interrupt (edge triggered at P3.2) , timer overflow interrupt(Timer 0)
and serial communication interrupt.
PROGRAM:
ORG 0x0000 ;RESET INTERRUPT
LJMP MAIN
ORG 0x0003 ;EXTERNAL INTERRUPT 0
CPL P1.0
RETI
ORG 0x000B ;TIMER 0 OVERFLOW INTERRUPT
CPL P1.1RETI
ORG 0x0023 ;SERIAL COMMUNICATION INTERRUPT
LJMP SERIAL_ISR
ORG 0x0030
MAIN:
MOV SCON,#0x50
MOV IE,#0x93 ;ENABLE EXT ,TIMER 0 , SERIAL INTERRUPT
MOV TMOD,#0x22
MOV TH0,#0x00
MOV TH1,#-3SETB TR0
SETB TR1
SETB IT0 ;EDGE TRIGERRED EXT. INTERRUPT
HERE:SJMP HERE
SERIAL_ISR:
CLR RI
MOV R0,SBUF
CJNE R0,#'y',C1
MOV P2,#0x00
C1:CJNE R0,#'n',C2
MOV P2,#0xFF
C2:RETI
-
7/25/2019 Microcontrollers Laboratory
20/38
ASSEMBLY LANGUAGE PROGRAMMING IN 8051
External interrupt toggles the LED connected with P1.0 , timer overflow interrupt will generate square wave P1.1
and serial interrupt for turning ON and OFF LEDs at Port 2
OUTPUT:
Figure 2.7(a) Windows showing Interrupts,Serial Communication
Figure 2.6(b) Windows showing Interrupts,Serial Communication
-
7/25/2019 Microcontrollers Laboratory
21/38
ASSEMBLY LANGUAGE PROGRAMMING IN 8051
RESULT:
Thus programs for Timers/Counters, Serial Communication and Interrupts were written in assembly andsimulated using Keil Vision IDE.
-
7/25/2019 Microcontrollers Laboratory
22/38
A. Timers /Counters
AIM:
i. To operate the timer0 in mode 0 and generate square wave of 66 % duty cycle.
ii. To operate the timer1 in mode 2 and generate a delay of 100 s.
iii. Count clock pulses on P3.4 (T0 pin) and put it on Port 2
PROGRAM:
i. For generating square wave of 66 % duty cycle using timer 0 in mode 0
C CODE:
#include
void delay1();
void delay2();
void main()
{
while(1)
{
P1|=(1
-
7/25/2019 Microcontrollers Laboratory
23/38
C PROGRAMMING IN 8051
OUTPUT:
Figure 3.1 Waveform at P1.5
ii. To operate the timer1 in mode 2 and generate a delay of 100 s.
C CODE:
#include
void delay();
void main()
{
TH1=-92; // 100 s/1.085 s = 92 for 11.592 MHz
TMOD=0x20;
while(1)
{
P1|=(1
-
7/25/2019 Microcontrollers Laboratory
24/38
C PROGRAMMING IN 8051
OUTPUT:
Figure 3.2 (a) Timer registers
Figure 3.2 (b) Timer registers
iii. Count clock pulses on P3.5 (T0 pin) and put it on Port 2
C CODE:
#includevoid main()
{
TMOD=0x50; //Counter 1 ,Mode 1
TH1=0x00;
T0=1;
while(1)
{
TR1=1;
while(!TF1)
P2=TL1;
TR1=0;
TF1=0;}
}
-
7/25/2019 Microcontrollers Laboratory
25/38
C PROGRAMMING IN 8051
OUTPUT:
Figure 3.3 Counter output
-
7/25/2019 Microcontrollers Laboratory
26/38
C PROGRAMMING IN 8051
B. Serial CommunicationAIM:
To turn on and turn off LEDs connected at PORT 1 by using serial communication. If y is sent LEDs are turned on
and if n is sent LEDs are turned off.Acknowledgment messages LEDs ON and LEDs OFF are also sent.
C CODE:
#include
void Serial_Init();
void Serial_Str_Transmit(char *);
char Serial_Char_Receive();
void main()
{
char ch;
Serial_Init();
while(1)
{
ch=Serial_Char_Receive();
switch(ch)
{
case 'y':
P1=0x00;
Serial_Str_Transmit("LEDs ON\n");
break;
case 'n':
P1=0xFF;
Serial_Str_Transmit("LEDs OFF\n");
break;
}
}
}
void Serial_Init()
{
TMOD=0x20;
SCON=0x50;
TH1=-3; // 9600 baud rate for 11.0592 MHz
TR1=1;
}
char Serial_Char_Receive()
{
while(!RI); //Poll RI flag
RI=0; //Clear RI flag
return(SBUF);
}
-
7/25/2019 Microcontrollers Laboratory
27/38
C PROGRAMMING IN 8051
void Serial_Str_Transmit(char *p)
{
while(*p!='\0')
{
SBUF=*p;
while(!TI); //Poll TI flag
TI=0;
p++;
}
}
OUTPUT:
Figure 3.4 Serial Communication
-
7/25/2019 Microcontrollers Laboratory
28/38
C PROGRAMMING IN 8051
C. Interrupts
AIM:
To write a program for demonstrating external interrupt (edge triggered at P3.2) , timer overflow interrupt(Timer 0)
and serial communication interrupt.
C CODE:
#include
void Serial_Init();
void Interrupt_Init();
void Timer0_Init();
void main()
{
Serial_Init();Interrupt_Init();
Timer0_Init();
while(1); // Wait forever
}
void Serial_Init()
{
TMOD=0x20;
SCON=0x50;
TH1=-3;
TR1=1;
}
void Interrupt_Init()
{
IE=0x93;
IT0=1;
}
void Timer0_Init()
{
TMOD|=0x02;
TR0=1;
}
void ext_int0(void) interrupt 0 //Ext.Interrupt 0
{
P1^=(1
-
7/25/2019 Microcontrollers Laboratory
29/38
C PROGRAMMING IN 8051
void serial_int(void) interrupt 4 //Serial Interrupt
{
RI=0;
if(SBUF=='y')
P2=0x00;
if(SBUF=='n')
P2=0xFF;
}
External interrupt toggles the LED connected with P1.0 , timer overflow interrupt will generate square wave P1.1
and serial interrupt for turning ON and OFF LEDs at Port 2
OUTPUT:
Figure 3.5 External ,Timer and Serial Communication interrupt
RESULT:
Thus assembly and C programs for Timers/Counters, Serial Communication and Interrupts in 8051
microcontroller were written and simulated using Keil Vision IDE.
-
7/25/2019 Microcontrollers Laboratory
30/38
AIM:
i. To turn on only RED LED (P1.4) when key 1(P2.0) is pressed and turn only GREEN LED(P1.5)
when key 2(P2.1) is pressed
ii. To produce a single beep sound when key 1 is pressed and a double beep sound when key 2 is
pressed.
iii. To interface HD44780 compatible 16 2 LCD display in 8 bit mode.
iv. To interface a 4 4 Matrix keypad.
PROGRAM:
i. To write a program to turn on only RED LED (P1.4) when key 1(P2.0) is pressed and turn only
GREEN LED(P1.5) when key 2(P2.1) is pressed.
#include
sbit RED =P1^4;
sbit GREEN =P1^5;
sbit KEY1=P2^0;
sbit KEY2=P2^1;
void main()
{
while(1)
{
if(!KEY1){
RED=0;
GREEN=1;
}
if(!KEY2)
{
RED=1;
GREEN=0;
}
}
4. INTERFACING HARDWARE WITH 8051Ex No : 4
16-11-15
-
7/25/2019 Microcontrollers Laboratory
31/38
INTERFACING HARDWARE WITH 8051
15EE51 Microcontrollers Laboratory Page 31
OUTPUT:
ii. To produce a beep sound when key 1 is pressed and a beep sound twice when key 2 is
pressed.
#include
void beep();
void delay_ms(int d);
sbit BUZZER = P3^4;
void main()
{
while(1)
{
if(!KEY1)
{
beep();
}
if(!KEY2)
{beep();
delay_ms(200);
beep();
}
}
Fig 4.1 RED LED glowing when Key1 is pressed Fig 4.2 GREEN LED glowing when Key2 is pressed
-
7/25/2019 Microcontrollers Laboratory
32/38
INTERFACING HARDWARE WITH 8051
15EE51 Microcontrollers Laboratory Page 32
void beep()
{
unsigned char i = 25;
while (i--)
{
BUZZER = !BUZZER;
delay(5);
}
}
void delay_ms(int d)
{
int i;
TCON=0x01;
for(i=0;i
-
7/25/2019 Microcontrollers Laboratory
33/38
INTERFACING HARDWARE WITH 8051
15EE51 Microcontrollers Laboratory Page 33
void main()
{
RW=0;
LCD_Init();
LCD_PrintStr("Jabez Winston");
delay_ms(1000);LCD_SetCursor(1,0);
LCD_PrintChar("Jagdeesh");
while(1);
}
void LCD_Init()
{
delay_ms(100);
LCD_Cmd(0x38);
delay_ms(10);
LCD_Cmd(0x0C);
LCD_Cmd(0x06);
LCD_Cmd(CLEAR);
}
void LCD_SetCursor(char r,char c)
{
switch(r)
{
case 0: LCD_Cmd(0x80+c);
break;
case 1: LCD_Cmd(0xC0+c);
break;
}
}
void LCD_Cmd(char cmd)
{
EN=0;
RS=0;P1=cmd;
EN=1;
delay_ms(10);
EN=0;
}
-
7/25/2019 Microcontrollers Laboratory
34/38
INTERFACING HARDWARE WITH 8051
15EE51 Microcontrollers Laboratory Page 34
void LCD_Data(char ch)
{
EN=0;
RS=1;
P1=ch;EN=1;
delay_ms(10);
EN=0;
}
void LCD_PrintChar(char ch)
{
LCD_Cmd(ch);
}
void LCD_PrintStr(char *s)
{
while(*s)
LCD_PrintChar(*s++);
}
void delay_ms(int d)
{
int i;
TCON=0x01;
for(i=0;i
-
7/25/2019 Microcontrollers Laboratory
35/38
INTERFACING HARDWARE WITH 8051
15EE51 Microcontrollers Laboratory Page 35
OUTPUT:
Figure 4.3 Two strings printed on LCD
iv. To interface a 4 4 Matrix keypad.
#include
unsigned char get_key();
void lcd_init();
void lcd_printc(char);void lcd_prints(char);
void lcd_clear();
void lcd_write_cmd(unsigned char );
void lcd_write_data(unsigned char );
void delay(int);
sbit LCD_RS = P2^4;
sbit LCD_WR = P2^5;
sbit LCD_EN = P2^6;
int x;
char a[4][4]={"123E",
"456U",
"789D",
"*0#e"};
-
7/25/2019 Microcontrollers Laboratory
36/38
INTERFACING HARDWARE WITH 8051
15EE51 Microcontrollers Laboratory Page 36
void main()
{
lcd_init();
while(1){
while(get_key()==-1);
x=get_key();
lcd_printc(x);
delay(100);
}
}
unsigned char get_key()
{
unsigned char i,j,k;
for(i=0;i
-
7/25/2019 Microcontrollers Laboratory
37/38
INTERFACING HARDWARE WITH 8051
15EE51 Microcontrollers Laboratory Page 37
}
void lcd_printc(char a_char)
{
lcd_write_data(a_char);
}
void lcd_prints(char *string)
{
while (*string)
lcd_printc(*string++);
}
void lcd_clear()
{
lcd_write_cmd(0x01);
}
void lcd_write_cmd(unsigned char cmd)
{
delay(10);
LCD_WR = 0;
LCD_EN = 0;
LCD_RS = 0; // Reset LCD_RS for Command
P0 = cmd;
LCD_EN = 1; // Pulse LCD_EN
LCD_EN = 0;
LCD_WR = 1;
}
void lcd_write_data(unsigned char val)
{
delay(10);
LCD_WR = 0;
LCD_EN = 0;
LCD_RS = 1; // SET LCD_RS for DATA
P0 = val;
LCD_EN = 1; // Pulse LCD_ENLCD_EN = 0;
LCD_WR = 1;
}
-
7/25/2019 Microcontrollers Laboratory
38/38
INTERFACING HARDWARE WITH 8051
void delay(unsigned int dval)
{
TMOD &= 0xF0;
TMOD |= 0x01;while (dval) {
TR0 = 0;
TF0 = 0;
TH0 = 0xFA;
TL0 = 0x00;
TR0 = 1;
while (TF0 == 0);
dval--;
}
TR0 = 0;
}
Fig 4.4 Matrix keypad and 16 x 2 LCD display
RESULT:
Thus LED,buzzer,matrix keypad and LCD were interfaced with 8051 starter kit.