INDEX
1. To write an Assembly Language Program to generate 10 KHz
square wave.
2. To write an Assembly Language Program to generate 10 KHz
frequency using interrupts.
3. To write an Assembly Language Program to interface one
Microcontroller with other using serial or parallel communication.
4. To write an Assembly Language Program for temperature and
pressure measurement and to display on intelligent LCD display.
5. To write an Assembly Language Program for PWM based
Regulator of voltage.
6. To study development tools/ environment for Microcontroller
Program.
7. To develop an Embedded System for traffic light controller using
Microcontroller.
8. To develop an Embedded System for the automatic motion of a car
(Model of car ) and subsequent display on LCD using
Microcontroller.
PROGRAM NO. 1
AIM: To write an Assembly Language Program to generate 10 KHz square wave.
PROGRAM:
org 0000h
again : mov tmod, #01h
mov t10, #0d2h
mov th0, #0ffh
setb tr0
back : JNB tf0, back
clr tr0
cpl p1.2
clr tf0
sjump again
end
OUTPUT: The 10 KHz square wave generated.
PROGRAM NO. 2
AIM: To write an Assembly Language Program to generate 10 KHz frequency using interrupts.
PROGRAM:
org 0000h
ljmp main
org 000bh
cpl p2.3
mov tl0, #0d2h
mov th0, #0ffh
reti
org 0030h
main : mov tmod, #01h
mov tl0, #d2h
mov th0, #0ffh
mov ie, #82h
setb tr0
again : mov p0, #0ffh
mov a, p0
mov p1, a
sjmp again
end
OUTPUT: The 10 KHz frequency was generated using interrupts.
PROGRAM NO. 3
AIM: To write an Assembly Language Program to interface one Microcontroller with other using serial
or parallel communication.
PROGRAM:
org 0000h
mov TMOD, #20h
mov TH1, #-3
mov SCON, #50h
setb TR1
loop : mov A, # “R”
acall SEND
mov A, #”A”
acall SEND
mov A, #”J”
acall SEND
mov A, #”A”
acall SEND
mov A, #”T”
acall SEND
sjmp loop
SEND : mov SBUF,A
here : jnb TI, here
clr T1
ret
end
OUTPUT: One microcontroller has been interfaced with other successfully.
PROGRAM NO. 4
AIM: To write an Assembly Language Program for temperature and pressure measurement and to
display
on intelligent LCD display.
PROGRAM:
org 0000h
mov a, #38h
acall command
acall delay
mov a, #0eh
acall command
acall delay
mov a, #01h
acall command
acall delay
mov a, #06h
acall command
acall delay
mov a, #84h
acall command
acall delay
mov a, #’T’
acall dataline
acall delay
mov a, #’E’
acall dataline
acall delay
mov a, #’M’
acall dataline
acall delay
mov a, #’P’
acall dataline
acall delay
mov a, #’E’
acall dataline
acall delay
mov a, #’R’
acall dataline
acall delay
mov a, #’A’
acall dataline
acall delay
mov a, #’T’
acall dataline
acall delay
mov a, #’U’
acall dataline
acall delay
mov a, #’R’
acall dataline
acall delay
mov a, #’E’
acall dataline
acall delay
command: mov p1,a
clr p2.0
clr p2.2
setb p2.1
acall delay
clr p2.1
ret
delay : mov r4, #0ffh
next : mov r3, #0ffh
here : djnz r3, here
djnz r4, next
ret
dataline : mov p1, a
setb p2.0
clr p2.2
setb p2.1
acall delay
clr p2.1
ret
end
OUTPUT: The temperature and pressure have been successfully measured and displayed on the LCD.
PROGRAM NO. 5
AIM: To write an Assembly Language Program for PWM based Regulator of voltage.
PROGRAM:
;Program [Link]
; illustrates use of the PWM command. Average voltage at PORTB.0 is
; ramped up from zero and then down from near +5.0. Process repeats.
LIST p=16c84
#include <c:\mplab\[Link]>
_CONFIG 11h
CONSTANT BASE_VAR=0CH
PWM_DUTY EQU BASE_VAR+0
PWM_LOOP EQU BASE_VAR+1
MAIN:
BSF STATUS, RP0
BSF TRISB, 0
BCF STATUS, RP0
CLRF PWM_DUTY
MAIN_1:
CALL PWM
INCFSZ PWM_DUTY, F
GOTO MAIN_1
MAIN_2:
CALL PWM
DECFSZ PWM_DUTY, F
GOTO MAIN_2
GOTO MAIN
PWM:
CLRF PWM_LOOP
BSF STATUS, RP0
BCF TRISB, 0
BCF STATUS, RP0
PWM_1:
ADDWF PWM_DUTY, W
BTFSS STATUS, C
BCF PORTB, 0
BTFSC STATUS, C
BSF PORTB, 0
DECFSZ PWM_LOOP, F
GOTO PWM_1
BSF STATUS, RP0
BSF TRISB, 0
RETURN
END
PROGRAM NO. 6
AIM: To study development tools/ environment for Microcontroller Program.
PROGRAM STEPS: The steps for development of 8051 Programs are as appended below:
A PC with Window Operating System
Integrated Development Environment (IDE)
Must learn to use the software
Programming and compiling the program making hex file
A software for transferring the hex file to Microcontroller using serial
communication port and interfacing circuitry
Once the user is in possession of a PC with Windows Operating System, he or
she can go for IDE. IDE is needed for programming Microcontrollers. A number
of softwares are available for programming microcontrollers. However, we will
limit our discussion with Keil u Vision3 IDE Software. This software can be
downloaded from [Link] with limited features or a licensed version
version can be obtained for usin all features.
The Flash Magic software for transferring the hex file from PC to
Microcontroller is also available on the website [Link].
OUTPUT: Development tools have been studied.
.
PROGRAM NO.7
AIM: To develop an Embedded System for traffic light controller using Microcontroller.
PROGRAM:
org 0000h
again : mov a, #09h
mov p0,a
mov a, #21h
mov p1,a
acall delay
mov a, #12h
mov p1,a
mov p0,a
acall delay 1
mov a, #0ch
mov p1, a
mov a, #21h
mov p0,a
acall delay
mov a, #12h
mov p1,a
mov p0,a
acall delay 1
SJMP AGAIN
delay : mov r0, #0ffh
here1 : mov tmod, #01h
mov th0, #00h
mov t10, #01h
setb tr0
here : jnb tf0, here
clr tr0
clr tf0
djnz r0, here 1
ret
delay 1 : mov tmod, #01h
mov th0, #00h
mov t10, #01h
setb tr0
BACK : jnb tf0, BACK
clr tr0
clr tf0
ret
end
OUTPUT: Required embedded system has been developed.
PROGRAM NO. 8
AIM: To develop an Embedded System for the automatic motion of a car (Model of car ) and subsequent
display on LCD using Microcontroller.
PROGRAM:
org 0000h
a1 : jb p1.0, start
jb p1.1, start1
sjmp a1
start : mov a, #38h
acall com
acall delay
mov a, #0eh
acall com
acall delay
mov a, #01h
acall com
acall delay
mov a, #06h
acall com
acall delay
mov a, #84h
acall com
acall delay
mov a, #’R’
acall dwrt
acall delay
mov a, #’I’
acall dwrt
acall delay
mov a, #’G’
acall dwrt
acall delay
mov a, #’H’
acall dwrt
acall delay
mov a, #’T’
acall dwrt
acall delay
start1: mov p0,#01h
acall delay
mov p0,#02h
acall delay
mov p0,#04h
acall delay
mov p0,#08h
acall delay
jnb p1.0,a2
ljmp start1
a2: jb p1.0,start
jb p1.1,start2
ljmp a2
start2: mov a,#38h
acall com
acall com
acall delay
mov a,#0eh
acall com
acall delay
mov a,#01h
acall com
acall delay
mov a,#06h
acall com
acall delay
mov a,#84h
acall com
acall delay
mov a,#’L’
acall dwrt
acall delay
mov a,#’E’
acall dwrt
acall delay
mov a,#’F’
acall dwrt
acall delay
mov a,#’T’
acall dwrt
acall delay
start3: mov p0,#08h
acall delay
acall delay
mov p0,#04h
acall delay
acall delay
mov p0,#02h
acall delay
acall delay
mov p0,#01h
acall delay
acall delay
jnb p1.1,a2
ljmp start3
com: mov p3,a
clr p2.0
clr p2.2
setb p2.1
clr p2.1
ret
dwrt: mov p3,a
setb p2.0
clr p2.2
setb p2.1
clr p2.1
ret
DELAY: MOV TMOD,#10H
MOV R3, #10
AGAIN: MOV TL1,#0f2H
MOV TH1,#0f0H
SETB TR1
BACK: JNB TF1,BACK
CLR TR1
CLR TF1
djnz r3,again
RET
END
OUTPUT: Required embedded system has been development.