Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 103

08.

607 Microcontroller Lab Manual

SREE BUDDHA COLLEGE OF ENGINEERING, PATTOOR


DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

08.607 MICROCONTROLLER LAB (TA) LAB MANUAL


Issue II, Version III

Prepared by: Pavi !a P P P""#a S. M"!a$

Dept. of ECE, Sree Buddha College of Engineering

08.607 Microcontroller Lab Manual

INSTRUCTIONS TO THE STUDENTS

G&$&'a()

All laws and rules of the SBCE apply to the use of this lab. In particular, uniform and attendance are compulsory. It is the responsibility of any user of the Institutional facilities to know and abide by all the Institutional regulations.

La+ R&,"' -)

Lab reports are re uired of indi!idual students, and are due one week after the corresponding e"periment has been completed. #eports should be neat and clearly organi$ed, and should include original data sheets.

Ca'& "/ E01i,2&$ -)

%lease be !ery careful with the lab e uipments. If you suspect something is not operating correctly, report it to the lab technician. If at any time you are uncertain about lab safety, please ask the lab&in&charge before proceeding. 'ake sure that all e uipment you used has been turned off and returned to the place you obtained it from.

Dept. of ECE, Sree Buddha College of Engineering

08.607 Microcontroller Lab Manual

3NO4 THE LABORATOR5 PRINCIPLES


La+"'a "'6 E7,&'i2&$ Laboratory e"periments are e"pected to de!elop intellectual skills, motor skills and learning attitudes in students. L"8i9a( T!i$:i$8 Logical thinking is de!eloped in students through system approach, content analysis and se uential planning of laboratory work. Sa/& 6 Instruments ha!ing electric circuits can be dangerous( hence safety practices are necessary to be followed to pre!ent electrical shock, fires, mechanical damage and in)uries resulting from improper use of tools. %erhaps the greatest ha$ard is electrical shock. A current through human body in e"cess of *+ milli ampere can paraly$e the !ictim. Connecting and disconnecting I,- systems should be done with the power switched off. P'"9&;1'& i$ ;&a(i$8 <i ! &(&9 'i9i 6 a$; &(&9 '"$i9 &01i,2&$ Always follow the procedure gi!en for conduct of e"periment. .se ser!ice manuals as often as possible. /hey often contain specific safety information. /hink before you act. 0hen in doubt, don1t act( ask your instructor or teacher.

S:i((- " +& ;&v&(",&; Can be able to identify logic behind each program. Able to prepare the complete program Enter and e"ecute the program.

Dept. of ECE, Sree Buddha College of Engineering

08.607 Microcontroller Lab Manual

08.607 MICROCONTROLLER LAB (TA) S6((a+1L=T= ) 0=0=>


A. P'"8'a22i$8 &7,&'i2&$ - 1-i$8 80?% T'ai$&' 3i . *. Addition and Subtraction of *2 bit numbers. 3. 'ultiplication and di!ision of 4 bit numbers. 5. Sorting, 6actorial of a number. 7. 'ultiplication by shift and add method. 8. LC' and 9C6 of two 4 bit numbers 2. 'atri" addition :. S uare, S uare root, 6ibonacci series. B. I$ &'/a9i$8 &7,&'i2&$ *. ;AC interface. 3. Stepper motor interface. 5. ;isplay interface. 7. #eali$ation of Boolean e"pression using port. 8. 6re uency measurement by counting the number of pulses in a fi"ed amount of time. 2. 6re uency measurement by measuring the time period between two consecuti!e pulses. :. 0a!eform generation using lookup tables. 4. %0' generation. <. Interfacing with 4&bit A;C. N" &) 6or .ni!ersity e"amination, the following guidelines should be followed regarding award of marks= (@1&- i"$- /"' &a9! +a 9! -!"1(; +& -&(&9 &; &01a((6 /'"2 ,a' A a$; B) >a? Circuit and design & 3+@ >b? Implementation>.sage of Aits and trouble shooting? & *8@ >c? #esult & 58@ >d? Bi!a !oce & 38@ >e? #ecord & +8@ P'a9 i9a( &7a2i$a i"$ " +& 9"$;19 &; 9"v&'i$8 &$ i'& -6((a+1- 8iv&$ a+"v&. S 1;&$ - -!a(( +& a(("<&; /"' !& U$iv&'-i 6 &7a2i$a i"$ "$(6 "$ -1+2i i$8 !& ;1(6 9&' i/i&; '&9"';. T!& &7 &'$a( &7a2i$&' -!a(( &$;"'-& !& '&9"';.

C'&;i -) >

Dept. of ECE, Sree Buddha College of Engineering

08.607 Microcontroller Lab Manual

CONTENTS
Pa8& N". *. 6amiliarisation of 4+8* microcontroller 3. 6amiliarisation of 4+8* microcontroller trainer kit 5. E"periment Set
A. P'"8'a22i$8 &7,&'i2&$ - 1-i$8 80?% T'ai$&' 3i . *. Addition and Subtraction of *2 bit numbers. 3. 'ultiplication and di!ision of 4 bit numbers. 5. Sorting, 6actorial of a number. 7. 'ultiplication by shift and add method. 8. LC' and 9C6 of two 4 bit numbers 2. 'atri" addition :. S uare, S uare root 4. 6ibonacci series generation. B. I$ &'/a9i$8 &7,&'i2&$ *. ;AC interface. 3. Stepper motor interface.

5. Interfacing with 4&bit A;C. 7. ;isplay Interfacing. 8. 0a!eform generation using lookup tables. 2. %0' generation :. #eali$ation of Boolean e"pression using port. 4. 6re uency measurement by counting the number of pulses in a fi"ed amount of time. <. 6re uency measurement by measuring the time period between two consecuti!e pulses.
*+. LE; blinking using Embedded c programming 11. A;C interfacing using embedded c programming *3. Stepper motor interfacing using Embedded C programming

4. Bi!a&!oce uestions 8. 'icrocontroller lab uestion bank

Dept. of ECE, Sree Buddha College of Engineering

08.607 Microcontroller Lab Manual

%. FAMILIARISATION OF 80?% MICROCONTROLLER


Ai2 /o familiarise with 4+8* microcontroller architectural features. 80?% Mi9'"9"$ '"((&' A 'icrocontroller is a programmable digital processor with necessary peripherals. Both microcontrollers and microprocessors are comple" se uential digital circuits meant to carry out )ob according to the program , instructions. Sometimes analog input,output interface makes a part of microcontroller circuit as mi"ed mode >both analog and digital? in nature. Applications of microcontrollers are numerous. Starting from domestic applications such as in washing machines, /Bs, air conditioners, microcontrollers are used in automobiles, process control industries, cell phones, electrical dri!es, and robotics and in space applications. Sa(i&$ /&a 1'& Eight bit C%. with registers A >Accumulator? and B Si"teen bit %rogram counter >%C? and a data pointer >;%/#? 4 Bit %rogram Status 0ord >%S0? 4 Bit Stack %ointer 7A Code 'emory Internal 'emory of *34 Bytes 53 I,- %ins arranged as 7 , 4 Bit ports /wo *2 Bit /imer,Counter =/+, /* 6ull ;uple" serial data recei!er,transmitter Control #egisters = /C-C,/'-;,SC-C,%C-C,I% and IE /wo E"ternal and Internal Interrupt sources

Dept. of ECE, Sree Buddha College of Engineering

08.607 Microcontroller Lab Manual

Fig.1. 80 1 !unctional bloc" diagra# M&2"'6 a$; R&8i- &' O'8a$i-a i"$ /he 4+8* has a separate memory space for code >programs? and data. It refers here to on& chip memory and e"ternal memory as shown in figure below >6ig3?. In an actual implementation the e"ternal memory may, in fact, be contained within the microcomputer chip. 9owe!er, we will use the definitions of internal and e"ternal memory to be consistent with 4+8* instructions which operate on memory. Cote, the separation of the code and data memory in the 4+8* architecture is a little unusual. /he separated memory architecture is referred to as Harvard architecture whereas Von Neumann architecture defines a system where code and data can share common memory.

Dept. of ECE, Sree Buddha College of Engineering

08.607 Microcontroller Lab Manual

Fig.$. 80 1 #e#ory representation E7 &'$a( C";& M&2"'6 /he e"ecutable program code is stored in this code memory. /he code memory si$e is limited to 27ABytes >in a standard 4+8*?. /he code memory is read-only in normal operation and is programmed under special conditions e.g. it is a %#-' or a 6lash #A' type of memory. E7 &'$a( RAM Da a M&2"'6 /his is read-write memory and is a!ailable for storage of data. .p to 27ABytes of e"ternal #A' data memory is supported >in a standard 4+8*?. I$ &'$a( M&2"'6 /he 4+8*1s on&chip memory consists of 382 memory bytes organi$ed as follows= irst !"# $ytes% ++h to *6h #egister Banks 3+h to 36h Bit Addressable #A' 5+ to :6h Deneral %urpose #A' Ne&t !"# $ytes% 4+h to 66h Special 6unction #egisters /he first *34 bytes of internal memory is organi$ed as shown in figure below >6ig7?, and is referred to as Internal #A', or I#A'. SFR D&-9'i, i"$ P0 (P"' 0, A;;'&-- 80!, Bi =A;;'&--a+(&)) /his is input,output port +. Each bit of this S6# corresponds to one of the pins on the microcontroller. 6or e"ample, bit + of port + is pin %+.+, bit : is pin %+.:. 0riting a !alue of * to a bit of this S6# will send a high le!el on the corresponding I,- pin whereas a !alue of + will bring it to a low le!el. SP (S a9: P"i$ &', A;;'&-- 8%!)) /his is the stack pointer of the microcontroller. /his S6# indicates where the ne"t !alue to be taken from the stack will be read from in Internal #A'. If you push a !alue onto the stack, the !alue will be written to the address of S% E *. /hat is to say, if S% holds the !alue +:h, a %.S9 instruction will push the !alue onto the stack at address +4h. /his S6# is modified by all instructions which modify the stack, such as %.S9, %-%, LCALL, #E/, #E/I, and whene!er interrupts are pro!oked by the microcontroller. DPLADPH (Da a P"i$ &' L"<AHi8!, A;;'&--&- 8*!A8.!)) /he S6#s ;%L and ;%9 work together to represent a *2&bit !alue called the Data 'ointer. /he data pointer is used in operations regarding e"ternal #A' and some instructions in!ol!ing code memory. Since it is an unsigned two&byte integer !alue, it can represent !alues from ++++h to 6666h >+ through 28,858 decimal?.

Dept. of ECE, Sree Buddha College of Engineering

08.607 Microcontroller Lab Manual

Fig.%. &rgani'ation o! internal ()M *I()M+ #e#ory PCON (P"<&' C"$ '"(, A;;'&--&- 87!)) /he %ower Control S6# is used to control the 4+8*Fs power control modes. Certain operation modes of the 4+8* allow the 4+8* to go into a type of GsleepG mode which re uires much less power. /hese modes of operation are controlled through %C-C. Additionally, one of the bits in %C-C is used to double the effecti!e baud rate of the 4+8*Fs serial port. TCON (Ti2&' C"$ '"(, A;;'&--&- 88!, Bi =A;;'&--a+(&)) /he /imer Control S6# is used to configure and modify the way in which the 4+8*Fs two timers operate. /his S6# controls whether each of the two timers is running or stopped and contains a flag to indicate that each timer has o!erflowed. Additionally, some non&timer related bits are located in the /C-C S6#. /hese bits are used to configure the way in which the e"ternal interrupts are acti!ated and also contain the e"ternal interrupt flags which are set when an e"ternal interrupt has occurred. TMOD (Ti2&' M";&, A;;'&--&- 8B!)) /he /imer 'ode S6# is used to configure the mode of operation of each of the two timers. .sing this S6# your program may configure each timer to be a *2&bit timer, an 4&bit auto reload timer, a *5&bit timer, or two separate timers. Additionally, you may configure the timers to only count when an e"ternal pin is acti!ated or to count Ge!entsG that are indicated on an e"ternal pin.

Dept. of ECE, Sree Buddha College of Engineering

08.607 Microcontroller Lab Manual

Fig.,. Me#ory #ap o! -pecial Function (egisters TL0ATH0 (Ti2&' 0 L"<AHi8!, A;;'&--&- 8A!A8B!)) /hese two S6#s, taken together, represent timer +. /heir e"act beha!ior depends on how the timer is configured in the /'-; S6#( howe!er, these timers always count up. 0hat is configurable is how and when they increment in !alue. TL%ATH% (Ti2&' % L"<AHi8!, A;;'&--&- 8C!A8D!)) /hese two S6#s, taken together, represent timer *. /heir e"act beha!ior depends on how the timer is configured in the /'-; S6#( howe!er, these timers always count up. 0hat is configurable is how and when they increment in !alue. P% (P"' %, A;;'&-- B0!, Bi =A;;'&--a+(&)) /his is input,output port *. Each bit of this S6# corresponds to one of the pins on the microcontroller. 6or e"ample, bit + of port * is pin %*.+, bit : is pin %*.:. 0riting a !alue of * to a bit of this S6# will send a high le!el on the corresponding I,- pin whereas a !alue of + will bring it to a low le!el. SCON (S&'ia( C"$ '"(, A;;'&--&- B8!, Bi =A;;'&--a+(&)) /he Serial Control S6# is used to configure the beha!ior of the 4+8*Fs on&board serial port. /his S6# controls the baud rate of the serial port, whether the serial port is acti!ated to recei!e data, and also contains flags that are set when a byte is successfully sent or recei!ed. SBUF (S&'ia( C"$ '"(, A;;'&--&- BB!)) /he Serial Buffer S6# is used to send and recei!e data !ia the on&board serial port. Any !alue written to SB.6 will be sent out the serial portFs /H; pin. Likewise, any !alue which the 4+8* recei!es !ia the serial portFs #H; pin will be deli!ered to the user program

Dept. of ECE, Sree Buddha College of Engineering

10

08.607 Microcontroller Lab Manual

!ia SB.6. In other words, SB.6 ser!es as the output port when written to and as an input port when read from. P* (P"' *, A;;'&-- A0!, Bi =A;;'&--a+(&)) /his is input,output port 3. Each bit of this S6# corresponds to one of the pins on the microcontroller. 6or e"ample, bit + of port 3 is pin %3.+, bit : is pin %3.:. 0riting a !alue of * to a bit of this S6# will send a high le!el on the corresponding I,- pin whereas a !alue of + will bring it to a low le!el. IE (I$ &''1, E$a+(&, A;;'&--&- A8!)) /he Interrupt Enable S6# is used to enable and disable specific interrupts. /he low : bits of the S6# are used to enable,disable the specific interrupts, where as the highest bit is used to enable or disable ALL interrupts. /hus, if the high bit of IE is + all interrupts are disabled regardless of whether an indi!idual interrupt is enabled by setting a lower bit. P. (P"' ., A;;'&-- B0!, Bi =A;;'&--a+(&)) /his is input,output port 5. Each bit of this S6# corresponds to one of the pins on the microcontroller. 6or e"ample, bit + of port 5 is pin %5.+, bit : is pin %5.:. 0riting a !alue of * to a bit of this S6# will send a high le!el on the corresponding I,- pin whereas a !alue of + will bring it to a low le!el. IP (I$ &''1, P'i"'i 6, A;;'&--&- B8!, Bi =A;;'&--a+(&)) /he Interrupt %riority S6# is used to specify the relati!e priority of each interrupt. -n the 4+8*, an interrupt may either be of low >+? priority or high >*? priority. An interrupt may only interrupt interrupts of lower priority. 6or e"ample, if we configure the 4+8* so that all interrupts are of low priority e"cept the serial interrupt, the serial interrupt will always be able to interrupt the system, e!en if another interrupt is currently e"ecuting. 9owe!er, if a serial interrupt is e"ecuting no other interrupt will be able to interrupt the serial interrupt routine since the serial interrupt routine has the highest priority. PS4 (P'"8'a2 S a 1- 4"';, A;;'&--&- D0!, Bi =A;;'&--a+(&)) /he %rogram Status 0ord is used to store a number of important bits that are set and cleared by 4+8* instructions. /he %S0 S6# contains the carry flag, the au"iliary carry flag, the o!erflow flag, and the parity flag. Additionally, the %S0 register contains the register bank select flags which are used to select which of the G#G register banks are currently selected. ACC (A99121(a "', A;;'&--&- E0!, Bi =A;;'&--a+(&)) /he Accumulator is one of the most used S6#s on the 4+8* since it is in!ol!ed in so many instructions. /he Accumulator resides as an S6# at E+h, which means the instruction MOC A, D*0! is really the same as MOC E0!, D*0!. 9owe!er, it is a good idea to use the first method since it only re uires two bytes whereas the second option re uires three bytes. B (B R&8i- &', A;;'&--&- F0!, Bi =A;;'&--a+(&)) /he GBG register is used in two instructions= the multiply and di!ide operations. /he B register is also commonly used by programmers as an au"iliary register to temporarily store !alues.

Dept. of ECE, Sree Buddha College of Engineering

11

08.607 Microcontroller Lab Manual

Fig. . Pin diagra# o! 80 1 80?% C("9: a$; I$- '19 i"$ 969(& /he heart of 4+8* is the circuitry that generates the clock pulses by which all internal operations are synchroni$ed. %ins H/AL* and H/AL3 are pro!ided for connecting resonator to form an oscillator. /he crystal fre uency is the basic internal fre uency of the microcontroller. 4+8* is designed to operate between *'9$ to *2'9$ and generally operates with a crystal fre uency **.+7<23 '9$ /he oscillator formed by the crystal, capacitor and an on&chip in!erter generates a pulse train at the fre uency of the crystal. /he clock fre uency f establishes the smallest inter!al to accomplish any simple instruction. /he time taken to complete any instruction is called as machine cycle or instruction cycle. In 4+8* one instruction cycle consists of 2 states or *3 clock cycles, instruction cycle is also referred as 'achine cycle.

Fig.6. Instruction cycle o! 80 1*Instruction cycle .as si/ states *- 1 0 - 6+. 1ac. state .as t2o pulses *P1 and P$++

Dept. of ECE, Sree Buddha College of Engineering

12

08.607 Microcontroller Lab Manual

A;;'&--i$8 2";&Immediate Addressing ;irect Addressing Indirect Addressing E"ternal ;irect Code Indirect '-B A,I3+h '-B A,5+h '-B A,J#+ '-BH A,J;%/# '-BC A,JAE;%/#

I22&;ia & A;;'&--i$8) Immediate addressing is so&named because the !alue to be stored in memory immediately follows the operation code in memory. /hat is to say, the instruction itself dictates what !alue will be stored in memory. Immediate addressing is !ery fast since the !alue to be loaded is included in the instruction. 9owe!er, since the !alue to be loaded is fi"ed at compile&time it is not !ery fle"ible. Di'&9 A;;'&--i$8 ;irect addressing is so&named because the !alue to be stored in memory is obtained by directly retrie!ing it from another memory location. ;irect addressing is generally fast since, although the !alue to be loaded isn1t included in the instruction, it is uickly accessible since it is stored in the 4+8*1s Internal #A'. It is also much more fle"ible than Immediate Addressing since the !alue to be loaded is whate!er is found at the gi!en address&&which may be !ariable. Also, it is important to note that when using direct addressing any instruction which refers to an address between ++h and :6h is referring to Internal 'emory. Any instruction which refers to an address between 4+h and 66h is referring to the S6# control registers that control the 4+8* microcontroller itself. I$;i'&9 A;;'&--i$8 Indirect addressing is a !ery powerful addressing mode which in many cases pro!ides an e"ceptional le!el of fle"ibility. Indirect addressing always refers to Internal #A'( it ne!er refers to an S6#. E7 &'$a( Di'&9 E"ternal 'emory is accessed using a suite of instructions which use what we call GE"ternal ;irectG addressing. It appears to be direct addressing, but it is used to access e"ternal memory rather than internal memory. E7 &'$a( I$;i'&9 E"ternal memory can also be accessed using a form of indirect addressing which is called as E"ternal Indirect addressing.

Dept. of ECE, Sree Buddha College of Engineering

13

08.607 Microcontroller Lab Manual

*. FAMILIARISATION OF 80?% MICROCONTROLLER TRAINER 3IT


Ai2 /o familiarise with 4+8* microcontroller trainer kit. I$- a((a i"$ /he power supply is pro!ided with a LE; as an indicator for the a!ailability of the power. /he trainer is issued a Kpower -C #esetL and the message is displayed in the display. If the message displayed is not in the prescribed format, then pressL#ESL key and check for the message. P'&9a1 i"$/o utilise the trainer kit to ad!antage, confirm to certain basic norms, and adhere to certain precautionary measures listed below as don1ts DONETS ;on1t insert any add&on card while the trainer is power -C. ;on1t tamper with any of the components in the trainer. ;on1t solder any wire from connectors when the power is up. 0ires are to be soldered only from the solder side of the board /he 32 pin headers should be used only with cables do not with wires soldered from the pins. ;o not attempt to ser!ice the trainer in the case of problems. G&$&'a( i$/"'2a i"$ /he hardware and software facilities a!ailable on 'icro&8* LC are discussed below. /he capabilities of the trainer with regard to memory, peripherals, and key functions are all mentioned here. F1$9 i"$a( B("9: Dia8'a2

Dept. of ECE, Sree Buddha College of Engineering

14

08.607 Microcontroller Lab Manual

Ha';<a'& -,&9i/i9a i"$-) i. P'"9&--"', 9("9: /'&01&$96 Intel 4+8*,4<C8* at *3'9$ >4<C8* ma" up to 55'9$?

ii.

M&2"'6 System E%#-' System #A' Additional #A' 'onitor Buffer .ser %rogram,;ata #A' area .ser ;ata #A' area 'emory mapped I,'emory mapped I,- e"pansion = = = = = = = = ++++&56669 M C+++&66669 7+++&B6669 ++++&56669 M C+++&6E669 7+++&7+669 7*++&B6669 ++++&56669 M C+++&6E669 66++&66*69, 66C+&66669 663+&66B69

iii.

I$,1 A"1 ,1 %arallel Serial = = 37 I,- lines using one numbers of 4388 * number of #S353 Serial interface using 4+8*Serial port /imer %rinter Interrupt = = = two *2 bit timers namely /imer + and /imer * -ne printer interface through 4388&I port 8 interrupt sources. Among them two are e"ternal interrupts called IC/+ and IC/*

iv.

LCD I$ &'/a9& *2"3 LC; display module

v.

IBM PC 3&6+"a'; i$ &'/a9&

vi.

P"<&' -1,,(6 S,&9i/i9a i"$-

Dept. of ECE, Sree Buddha College of Engineering

15

08.607 Microcontroller Lab Manual

'odel 'ain -utputs

= = =

S'%S 35+Bolts AC at 8+ 9$ i. ii. iii. i!. E8B, 5Amps #egulated E*3B, *8+mA #egulated &*3B, *8+mA #egulated E5+B, 8++mA #egulated

vii.

P!6-i9a( C!a'a9 &'i- i9'icro&8* LC %CB 0eight = = 2.4Lmm " 2.4Lmm *,3 Ag

viii.

B1- E7,a$-i"$

A B/HNBus has been incorporated in 'icro&8* LC which facilitates to patch up any e"tra hardware to 'icro&8* LC. An unlimited number of add&on boards could be added this way to interface the hardware a!ailable on 'icro&8* LC. All buffered address, data and control signals are brought out this bus. .sing B/HNBus, BB'B cards can be directly interfaced with 'icro&8* LC.

/he power supply used is meant only for the trainer and the add&on boards used along with the trainer. /his power supply must not be used for any e"ternal applications.

S"/ <a'& -,&9i/i9a i"$-)

/he 'icro&8* LC can accept any command related to the following short listed function once in the command prompt mode, indicated byKIL in the leftmost position of the second row in the LC; module. /he functions that can be performed using the commands are as follows= ;isplay and Substitute memory locations

Dept. of ECE, Sree Buddha College of Engineering

16

08.607 Microcontroller Lab Manual

;isplay and modify registers of the C%. Enter and initiate e"ecution of user programs ;ebug the user program through the trace facility pro!ided by the monitor 6ill a block of memory to #A' or within #A' 'o!e a block of memory to #A' or within #A' Compare two blocks of memory Insert bytes to #A' memory ;elete bytes from #A' memory Input a byte from an input port -utput a byte to an output port /ransmit or recei!e a block of data through the serial port %rint a block of memory ;isplay a block of memory contents Biew a byte in the internal #A' locations>++ to 669?

'icro&8* LC contains a high performance 53A bytes monitor program. It is designed respond to user input, #S353C serial communications, printer interface through 4388&I port etc. /he following is a simple description of the commands in 'icro&8* LC.

%. S1+- i 1 & 2&2"'6 9"22a$; IS%OAddrPOC#P IS%OAddrPOC#P *. R&8i- &' Ci&<AM";i/6 I#OC#P .. a)GO 9"22a$; D-OAddrPOC#P +) GO <i ! +'&a: ,"i$ D-OStart AddrPOEnd AddrPOC#P >. T'a9& 9"22a$; I/#OAddrPOC#P

&for program memory &for data memory

Dept. of ECE, Sree Buddha College of Engineering

17

08.607 Microcontroller Lab Manual

?. Fi(( 9"22a$; I6%OStart AddrPOEnd AddrPO;ataPOC#P I6;OStart AddrPOEnd AddrPO;ataPOC#P

&for program memory &for data memory

6. B("9: 2"v& 9"22a$; I'%OStart AddrPOEnd AddrPO;est AddrPOC#P &for program memory I';OStart AddrPOEnd AddrPO;est AddrPOC#P &for data memory 7. B("9: 9"2,a'& 9"22a$; IC%OStart AddrPOEnd AddrPO;est AddrPOC#P IC;OStart AddrPOEnd AddrPO;est AddrPOC#P &for program memory &for data memory

8. I$-&' 9"22a$; II%OInsert AddrPO%rogram End AddrPOCo. of bytesPOC#P II;OInsert AddrPO;ata 'em End AddrPOCo. of bytes POC#P B. D&(& & 9"22a$; IE%OStart AddrPOEnd AddrP O%rogram End AddrPOC#P IE;OStart AddrPOEnd AddrPO;ata 'em End AddrPOC#P %0. I$,1 9"22a$; IIC O%ort AddrPOC#P %%. O1 ,1 9"22a$; I-O%ortAddrPO;ataPOC#P %*. S&'ia( I$,1 9"22a$; I%IOStart AddrPOC#P I;IOStart AddrPOC#P %.. S&'ia( O1 ,1 9"22a$; I%-OStart AddrPOEnd AddrPOC#P I;-OStart AddrPOEnd AddrPOC#P %>. P'i$ 9"22a$; I%%OStart AddrPOEnd AddrPOC#P I%;OStart AddrPOEnd AddrPOC#P %?. D12, 2&2"'6 9"$ &$ I;%OStart AddrPOEnd AddrPOC#P I;;OStart AddrPOEnd AddrPOC#P %6. I$ &'$a( 9"22a$; II#O AddrPOC#P %7. A--&2+(& IAOC#P &for program memory &for data memory. &for program memory &for data memory &for program memory &for data memory &for program memory &for data memory

Dept. of ECE, Sree Buddha College of Engineering

18

08.607 Microcontroller Lab Manual

%8. U$a--&2+(& I.OC#P %B. EPROM ,'"8'a22&' IEOC#P >/o program the E%#-'s like 3:*2,3:53 etc? *0. S&'ia( 2";& IS'OC#P >/o access the kit !ia serial port? GENERAL PROCEDURE TO CODE IN TO THE 3IT

/he procedure to enter the user program into trainer kit and e"ecute it is discussed below. E"ecution of a program can be done either using the unconditional D- and EHEC command or using the S/E% command.

4'i i$8 a ,'"8'a2 0rite an appropriate program in the form of mnemonic codes. /his program has to be entered into the kit in the form of he" codes. /hese are called ob)ect codes which can be fount by referring to the instruction set gi!en in the 'icro&8* LC .ser 'anual.

E$ &'i$8 !& ,'"8'a2 a$; &7&91 i$8 i /he program can be e"ecuted directly placing the opcodes in the memory and entering a D- command. /he procedure is as follows= *. Enter substitute byte command 3. Enter the opcodes from 7*++ location 5. After entering the program, come back to command prompt 7. Cow issue the D- command /he program will now be e"ecuted T'a9i$8 !& ,'"8'a2

Enter the trace command, it can be seen that instruction at location 7*++ is being e"ecuted and the ne"t instruction is displayed. By pressing carriage return, this instruction can be e"ecuted. /hus trace each step in the program by single stepping and register !iew.

Dept. of ECE, Sree Buddha College of Engineering

19

08.607 Microcontroller Lab Manual

A--&2+(&' (i- "1

An assembler list out can be written in 4+8* mnemonics. /he list out should include line number, memory location address, -pcode and operands, label, mnemonics and operand. And the program should in!ol!e a lot of assembler directi!es like the -#D, EQ., EC; and many more. It is a must that one should use these directi!es while assembling programs in %C.

.. EFPERIMENT SET
C5CLE=% *. Addition and subtraction of *2 bit numbers. 3. 'ultiplication and di!ision of 4 bit numbers. 5. Sorting a set of numbers. 7. 6actorial of a number. 8. LC' and 9C6 of two 4 bit numbers. 2. 'ultiplication by shift and add method. C5CLE=* :. 'atri" addition. 4. S uare and s uare root of a number. <. 6ibonacci series generation. *+. ;AC Interfacing. **. Stepper motor interfacing. *3. Interfacing with 4&bit A;C. C5CLE=. *5. ;isplay Interfacing. *7. 0a!eform generation using lookup tables. *8. %0' generation *2. #eali$ation of Boolean e"pression using port.

Dept. of ECE, Sree Buddha College of Engineering

20

08.607 Microcontroller Lab Manual

*:. 6re uency measurement by counting the number of pulses in a fi"ed amount of time. *4. 6re uency measurement by measuring the time period between two consecuti!e pulses.
*<. LE; blinking using Embedded c programming 20. A;C interfacing using embedded c programming 3*. Stepper motor interfacing using Embedded C programming

PART A PROGRAMMING EFPERIMENTS USING 80?% TRAINER 3IT

Dept. of ECE, Sree Buddha College of Engineering

21

08.607 Microcontroller Lab Manual

FLO4 CHART) A;;i i"$ "/ <" %6 +i $12+&'-

Dept. of ECE, Sree Buddha College of Engineering

22

08.607 Microcontroller Lab Manual

E"p Co = *

Dept. of ECE, Sree Buddha College of Engineering

23

08.607 Microcontroller Lab Manual

;ate

ADDITION AND SUBTRACTION OF %6 BIT NUMBERS


Ai2 /o find the sum and difference of two *2 bit numbers and store the result in a memory location. A,,a'a 1- R&01i'&;) N" * Na2& 'icrocontroller kit @1a$ i 6 *

A(8"'i !2) A;;i i"$ "/ <" %6 +i $12+&'*. Start the program. 3. 'o!e the first data lower order byte to A register. 5. Add the second data lower order byte with A register. 7. 'o!e the lower order byte result data from A reg to 45++ 'emory location. 8. 'o!e the first data higher order byte to A register. 2. Add A reg. and Second higher order byte with carry flag. :. 'o!e the higher order byte result data from A reg to 45+* 'emory location. 4. Check the carry flag( if it is one mo!e +* data to 45+3 else mo!e ++ data to 45+3. <. Stop the program. S1+ 'a9 i"$ "/ <" %6 +i $12+&'*. Start the program. 3. 'o!e the first data lower order byte to A register. 5. Subtract the second data lower order byte from A register. 7. 'o!e the lower order byte result data from A reg to 45++ 'emory location. 8. 'o!e the first data higher order byte to A register. 2. Subtract A reg. and Second higher order byte with carry flag. :. 'o!e the higher order byte result data from A reg to 45+* 'emory location. 4. Stop the program.

Dept. of ECE, Sree Buddha College of Engineering

24

08.607 Microcontroller Lab Manual

FLO4 CHART) S1+ 'a9 i"$ "/ <" %6 +i $12+&'-

S/A#/

'o!e the Lower order byte of ;ata* to Acc. #eg Subtract Acc. #eg with Lower order byte of ;ata3 'o!e the Lower order byte result from Acc. #eg to the 'emory location 45++h

'o!e the 9igher order byte of ;ata* to Acc. #eg

Subtract Acc. #eg and 9igher order byte of ;ata3 with carry 'o!e the 9igher order byte result from Acc. #eg to the 'emory location 45+*h
Stop

Dept. of ECE, Sree Buddha College of Engineering

25

08.607 Microcontroller Lab Manual

P'"8'a2) A;;i i"$ "/ <" %6 +i $12+&'M&2"'6 a;;'&-H&7. 9";& La+&( A--&2+(6 C";&C"22&$ -

O1 ,1 )
M&2"'6 A;;'&-Da a

P'"8'a2) S1+ 'a9 i"$ "/ <" %6 +i $12+&'M&2"'6 a;;'&-H&7. 9";& La+&( A--&2+(6 C";&C"22&$ -

Dept. of ECE, Sree Buddha College of Engineering

26

08.607 Microcontroller Lab Manual

O1 ,1 )
M&2"'6 A;;'&-Da a

R&-1( ) /hus assembly language programs were written to add and subtract two *2 bit numbers and e"ecuted successfully. R&/&'&$9&) /he 4+8* 'icrocontroller and Embedded Systems & 'uhammad Ali 'a$idi, Ranice Dillispie 'a$idi.

Dept. of ECE, Sree Buddha College of Engineering

27

08.607 Microcontroller Lab Manual

FLO4 CHART) T<" 8 Bi M1( i,(i9a i"$

Start

'o!e the ;ata* from 'em.Location 73++ to B reg 'o!e the ;ata3 from mem.Location 73+* to Acc Acc. reg 'ultiply reg Acc. #eg with B #eg.

'o!e the #esult from Acc. #eg. to 'emory Location 78+*h 'o!e the #esult from B. #eg to 'emory Location 78++h

Stop

Dept. of ECE, Sree Buddha College of Engineering

28

08.607 Microcontroller Lab Manual

E"p Co = 3 ;ate =

MULTIPLICATION AND DICISION OF 8 BIT NUMBERS


Ai2 /o perform 4&bit 'ultiplication and ;i!ision of two 4&bit data using indirect addressing and store the result in memory. A,,a'a 1- R&01i'&;) N" * Na2& 'icrocontroller kit @1a$ i 6 *

A(8"'i !2) T<" 8 Bi M1( i,(i9a i"$ *. 'o!e the multiplicand to accumulator. 3. 'o!e the multiplier to SB1 register >S6# with direct address 6-? 5. 'ultiply the contents of Accumulator and SB1 register. 7. Store the lower byte result from SA1 register to 78+* memory location 8. Store the higher byte result from SB1 register to 78++ memory location 2. Stop or 9alt the program e"ecution. Divi-i"$ "/ <" 8 +i $12+&'*. 'o!e the di!idend to accumulator. 3. 'o!e the di!isor to SB1 register >S6# with direct address 6-? 5. ;i!ide the contents of Accumulator and SB1 register. 7. Store the lower byte result from SA1 register to 78+* memory location 8. Store the higher byte result from SB1 register to 78++ memory location 2. Stop or 9alt the program e"ecution.

Dept. of ECE, Sree Buddha College of Engineering

29

08.607 Microcontroller Lab Manual

FLO4 CHART) Divi-i"$ "/ <" 8 +i $12+&'-

Start

'o!e the ;ata* from 'em.Location 73++ to B reg 'o!e the ;ata3 from mem.Location 73+* to Acc. reg ;i!idereg Acc. #eg with B #eg.

'o!e the #esult from Acc. #eg. to 'emory Location 78++h 'o!e the #esult from B. #eg to 'emory Location 78+*h

Stop

Dept. of ECE, Sree Buddha College of Engineering

30

08.607 Microcontroller Lab Manual

P'"8'a2) T<" 8 Bi M1( i,(i9a i"$

M&2"'6 a;;'&--

H&7. 9";&

La+&(

A--&2+(6 C";&-

C"22&$ -

I$,1 )
M&2"'6 Da a

O1 ,1 )
M&2"'6 A;;'&-Da a

Dept. of ECE, Sree Buddha College of Engineering

31

08.607 Microcontroller Lab Manual

P'"8'a2) Divi-i"$ "/ <" 8 +i $12+&'M&2"'6 a;;'&-H&7. 9";& La+&( A--&2+(6 C";&C"22&$ -

I$,1 )
M&2"'6 Da a

O1 ,1 )
M&2"'6 A;;'&-Da a

R&-1( ) /hus assembly language programs were written to multiply and di!ide two 4 bit numbers and e"ecuted successfully. R&/&'&$9&) /he 4+8* 'icrocontroller and Embedded Systems & 'uhammad Ali 'a$idi, Ranice Dillispie 'a$idi.

Dept. of ECE, Sree Buddha College of Engineering

32

08.607 Microcontroller Lab Manual

FLO4 CHART) S"' i$8 a -& "/ $12+&'Start

#ead the length of array, Count #5U#7UCount&*

Load data pointer with initial location address of array

#8#2U ;%/# #ead the element pointed by ;%/# from array and store in B

#ead the ne"t element from Array and store in A

Is AP BV

CE"change A and B

TES

Increment pointer and decrement #5

CIs #5U+V

;%/#U #8#2

Increment pointer and decrement #7

C-

Is #7U+V

Stop

Dept. of ECE, Sree Buddha College of Engineering

33

08.607 Microcontroller Lab Manual

E"p Co = 5 ;ate =

SORTING A SET OF NUMBERS


Ai2 /o write and e"ecute an assembly language program to arrange an 4 bit array of datas in ascending order. A,,a'a 1- R&01i'&;) N" * Na2& 'icrocontroller kit @1a$ i 6 *

A(8"'i !2) S"' i$8 a -& "/ $12+&'*= Start 3= #ead the length of the array, Count. 5= #5U#7UCount &* 7= #ead the element in array pointed by data pointer and store in B. 8= #ead the ne"t element from array and store in A 2= Is APB If no, e"change the !alues of A and B. := Increment the pointer and decrement #5. 4= Is #5U+ If no, go to step 8 <= Load the data pointer with the initial !alue >first location of array?. *+= Increment the pointer and decrement #7. **= Is #7U+ If no, go to step 7. *3= Stop

Dept. of ECE, Sree Buddha College of Engineering

34

08.607 Microcontroller Lab Manual

P'"8'a2) S"' i$8 a -& "/ $12+&'M&2"'6 a;;'&-H&7. 9";& La+&( A--&2+(6 C";&C"22&$ -

Dept. of ECE, Sree Buddha College of Engineering

35

08.607 Microcontroller Lab Manual

I$,1 )
M&2"'6 4500 4501 4502 4503 4504 Da a ;ata * ;ata 3 ;ata 5 ;ata 7 ;ata 8

O1 ,1 )
M&2"'6 4500 4501 4502 4503 4504 Da a ;ata * ;ata 3 ;ata 5 ;ata 7 ;ata 8

R&-1( ) /hus an assembly language program was written to arrange 4 bit array of datas in ascending order and it was e"ecuted successfully.

R&/&'&$9&) /he 4+8* 'icrocontroller and Embedded Systems & 'uhammad Ali 'a$idi, Ranice Dillispie 'a$idi.

Dept. of ECE, Sree Buddha College of Engineering

36

08.607 Microcontroller Lab Manual

FLO4 CHART) Fa9 "'ia( "/ a $12+&'

Start

#ead the number C

#+U#7UC and BU*

AU#+

%UA H B AUB and #8UBU%

;ecrement #+ and #7

C-

Is #7U +?

TES
0rite #8 into output memory location

Stop

Dept. of ECE, Sree Buddha College of Engineering

37

08.607 Microcontroller Lab Manual

E"p Co = 7 ;ate =

FACTORIAL OF A NUMBER
Ai2 /o write and e"ecute an assembly language program to find the factorial of a gi!en number. A,,a'a 1- R&01i'&;) N" * Na2& 'icrocontroller kit @1a$ i 6 *

A(8"'i !2) Fa9 "'ia( "/ a $12+&' *= Start 3= #ead the number C from e"ternal memory location. 5= #+U#7UC and BU* 7= AU#+. 8= 'ultiply A and B. 2= Sa!e the product into #8.Also reload the B with the product. := ;ecrement #+ 4= ;ecrement #7 <= Check whether #7U+ If no, go to step 7 If yes, write the !alue of #8 to output memory location. *+= Stop

Dept. of ECE, Sree Buddha College of Engineering

38

08.607 Microcontroller Lab Manual

P'"8'a2) Fa9 "'ia( "/ a $12+&'

M&2"'6 a;;'&--

H&7. 9";&

La+&(

A--&2+(6 C";&-

C"22&$ -

I$,1 )
M&2"'6 4200 Da a

O1 ,1 )
M&2"'6 4500 Da a

R&-1( ) /hus an assembly language program was written to find the factorial of a gi!en number and it was e"ecuted successfully.

R&/&'&$9&) /he 4+8* 'icrocontroller and Embedded Systems & 'uhammad Ali 'a$idi, Ranice Dillispie 'a$idi.

Dept. of ECE, Sree Buddha College of Engineering

39

08.607 Microcontroller Lab Manual

FLO4 CHART) LCM "/ <" 8 +i $12+&'Start

Enter two 4 bit numbers and sa!e them in #3 and #5. Initiali$e register #*U+*h.

Load Accumulator with !alue in #3 and load register B with !alue in #*. 'ultiply A and B. Load registers #2 and #: with !alues in A and B respecti!ely. Load register B with !alue in #5. ;i!ide A and B. Load A with !alue in B. increment #* Is remainderU+ V TES 0rite the !alues of #: and #2 to output memory location. location.
Stop

C-

Dept. of ECE, Sree Buddha College of Engineering

40

08.607 Microcontroller Lab Manual

E"p Co = 8 ;ate =

LCM AND HCF OF T4O 8 BIT NUMBERS


Ai2 /o write and e"ecute an assembly language programs to find the highest common factor >9C6? and least common multiplier >LC'? of two 4 bit numbers. A,,a'a 1- R&01i'&;) N" * Na2& 'icrocontroller kit @1a$ i 6 *

A(8"'i !2) LCM "/ <" 8 +i $12+&'-. *= Start 3= Initiali$e register #*U+*h. 5= Enter two 4 bit numbers and sa!e them in #3 and #5. 7= Load Accumulator with !alue in #3 and load register B with !alue in #*. 8= 'ultiply A and B. 2= Load registers #2 and #: with !alues in A and B respecti!ely. := Load register B with !alue in #5. 4= ;i!ide A and B. <= Load A with !alue in B. *+= Check whether the remainder of di!ision is $ero If no, increment #* and go to step 7 If yes, write the !alues of #: and #2 to output memory location. **= Stop HCF "/ <" 8 +i $12+&'-. Start Enter two 4 bit numbers and sa!e them in #+ and #*. Load Accumulator with !alue in #+ and load register B with !alue in #*. Is APB, If no, e"change the !alues of A and B and load the !alues in A and B to registers #+ and #* respecti!ely. 8= Load registers B and A with !alues in #* and #+ respecti!ely. 2= ;i!ide A and B. := Load A with !alue in B. 4= Check whether the remainder of di!ision is $ero If no, load #+ with !alue in #*, #* with !alue in register B and go to step 8 If yes, write the !alues of #* to output memory location. **= Stop *= 3= 5= 7=

Dept. of ECE, Sree Buddha College of Engineering

41

08.607 Microcontroller Lab Manual

FLO4 CHART) HCF "/ <" 8 +i $12+&'Start

Enter two 4 bit numbers and sa!e them in #+ and #*. Load Accumulator with !alue in #+ and load register B with !alue in #*.

Is APBV CTES Load registers B and A with !alues in #* and #+ respecti!ely. ;i!ide A and B. E"change the !alues of A and B and load the !alues in A and B

Load A with !alue in B.

Load #+ with !alue in #* and #* with !alue in register B

C-

Is remainderU+ V TES

0rite the !alues of #* to output memory location. location.


Stop

Dept. of ECE, Sree Buddha College of Engineering

42

08.607 Microcontroller Lab Manual

P'"8'a2) LCM "/ <" 8 +i $12+&'M&2"'6 a;;'&-H&7. 9";& La+&( A--&2+(6 C";&C"22&$ -

I$,1 )
M&2"'6 4200 4201 Da a Data1 Data 2

O1 ,1 )
M&2"'6 4500 4501 Da a Higher order byte Lower order byte

Dept. of ECE, Sree Buddha College of Engineering

43

08.607 Microcontroller Lab Manual

P'"8'a2) HCF "/ <" 8 +i $12+&'M&2"'6 a;;'&-H&7. 9";& La+&( A--&2+(6 C";&C"22&$ -

I$,1 )
M&2"'6 4200 4201 Da a Data1 Data 2

O1 ,1 )
M&2"'6 4500 Da a

R&-1( ) /hus an assembly language programs were written to find the LC' and 9C6 of a gi!en number and it was e"ecuted successfully. R&/&'&$9&) /he 4+8* 'icrocontroller and Embedded Systems & 'uhammad Ali 'a$idi, Ranice Dillispie 'a$idi.

Dept. of ECE, Sree Buddha College of Engineering

44

08.607 Microcontroller Lab Manual

FLO4 CHART) M1( i,(i9a i"$ +6 S!i/ a$; A;; 2& !"; Start #+W;ata*, #*W;ata 3 #3W+, #5W4 >Count? AW#*, AWA >AC; ? +*9 #7WA C#7 U* TES AW#3, AWAE#+Ecarry #3WA

AW#+

Shift A left, #+WA

AW#*, Shift A right, #*WA

Count W Count&*

NO

Is Count U+ V
YES

Store the !alue of #3 to output memory location Stop E"p Co = 2

Dept. of ECE, Sree Buddha College of Engineering

45

08.607 Microcontroller Lab Manual

;ate

MULTIPLICATION B5 SHIFT AND ADD METHOD


Ai2 /o write and e"ecute an assembly language program to find the product of two 4&bit numbers using repeat addition method. A,,a'a 1- R&01i'&;) N" * Na2& 'icrocontroller kit @1a$ i 6 *

A(8"'i !2) M1( i,(i9a i"$ +6 S!i/ a$; A;; 2& !"; *= Start 3= Enter two 4 bit numbers and sa!e them in #+ and #*. 5= Initiali$e 3 registers #3U +for output storage and #5U4 >count? 7= Load accumulator with #* and AC; Accumulator with +*9 8= Load #7 with accumulator 2= Check whether #7U* If C- go to step 4 If TES AccU#3 := Add Acc and #+, with carry and load #3 with Accumulator. 4= Load accumulator with !alue in #+ <= #otate Accumulator to left and load #+ with Accumulator *+= #eload accumulator with !alue in #* **= #otate Accumulator to right and load Accumulator to #* *3= ;ecrement Count and check whether it is e ual to $ero If non&$ero, go to step 7 *5= -utput the !alue in output registers *7= Stop

P'"8'a2) M1( i,(i9a i"$ +6 S!i/ a$; A;; 2& !";

Dept. of ECE, Sree Buddha College of Engineering

46

08.607 Microcontroller Lab Manual

M&2"'6 a;;'&--

H&7. 9";&

La+&(

A--&2+(6 C";&-

C"22&$ -

I$,1 )
M&2"'6 4200 4201 Da a Data1 Data 2

O1 ,1 )
M&2"'6 4500 Da a

R&-1( ) /hus an assembly language program was written to find the product of two 4 bit numbers and it was e"ecuted successfully R&/&'&$9&) /he 4+8* 'icrocontroller and Embedded Systems & 'uhammad Ali 'a$idi, Ranice Dillispie 'a$idi. FLO4 CHART) Ma 'i7 a;;i i"$

Dept. of ECE, Sree Buddha College of Engineering

47

08.607 Microcontroller Lab Manual

Start

Sa!e the matrices in e"ternal memory

#ead the element of first matri" from its memory location using data pointer.

#ead the element of second matri" from its memory location Add them using data %ointer. Add them

Store the sum into corresponding memory location using data pointer.

Stop

E"p Co = :

Dept. of ECE, Sree Buddha College of Engineering

48

08.607 Microcontroller Lab Manual

;ate

MATRIF ADDITION
Ai2 /o write and e"ecute an assembly language program to add two 3X3 matrices and sa!e the output to specified memory location. A,,a'a 1- R&01i'&;) N" * Na2& 'icrocontroller kit @1a$ i 6 *

A(8"'i !2) Ma 'i7 a;;i i"$ *= Start 3= Sa!e the matrices in e"ternal memory 5= #ead the element of first matri" from its memory location using data pointer. 7= #ead the element of second matri" from its memory location using data %ointer. 8= Add the two elements 2= Store the sum into corresponding memory location using data pointer. := Stop

Dept. of ECE, Sree Buddha College of Engineering

49

08.607 Microcontroller Lab Manual

P'"8'a2) Ma 'i7 a;;i i"$ M&2"'6 a;;'&-H&7. 9";& La+&( A--&2+(6 C";&C"22&$ -

Dept. of ECE, Sree Buddha College of Engineering

50

08.607 Microcontroller Lab Manual

I$,1 )
M&2"'6 4200 4201 4202 4203 Da a Data1 Data 2 Data3 Data 4 M&2"'6 4300 4301 4302 4303 Da a Data1 Data 2 Data3 Data 4

O1 ,1 )
M&2"'6 4500 4501 4502 4503 Da a Data1 Data 2 Data3 Data 4

R&-1( ) /hus an assembly language program was written to find the sum of two 3X3 matrices and it was e"ecuted successfully

R&/&'&$9&) /he 4+8* 'icrocontroller and Embedded Systems & 'uhammad Ali 'a$idi, Ranice Dillispie 'a$idi.

Dept. of ECE, Sree Buddha College of Engineering

51

08.607 Microcontroller Lab Manual

FLO4 CHART) S01a'& "/ a $12+&'.


Start #ead the number C

'ultiply C with itself to obtain the s uare of C

-utput the S uare of C

Stop

FLO4 CHART) S01a'& '"" "/ a $12+&'.

Start #ead the number C

iU *

QU C,i

;U Q& i iU iE*

CIs ;U+ TE V

TES

-utput s uare rootU Q

Stop

Dept. of ECE, Sree Buddha College of Engineering

52

08.607 Microcontroller Lab Manual

E"p Co = 4 ;ate =

S@UARE AND S@UARE ROOT OF A NUMBER


Ai2 /o write and e"ecute an assembly language programs to find the s uare and s uareroot of a gi!en number and sa!e the output to specified memory location. A,,a'a 1- R&01i'&;) N" * Na2& 'icrocontroller kit A(8"'i !2) S01a'& "/ a $12+&' *= Start 3= #ead the number 5= 'ultiply the number with itself 7= ;isplay the product found, which is the s uare of the number. 8= Stop S01a'& '"" "/ a $12+&'. *= Start 3= #ead the number, C 5= Initiali$e a !ariable iU* 7= ;i!ide the number C by i 8= Sa!e the uotient and remainder of di!ision 2= Subtract the !ariable i from the uotient obtained := Check whether this difference is e ual to $ero If no increment the !alue of Si1 and go to step 7 If yes, output the !alue of 1Q1 as the s uare root 4= Stop @1a$ i 6 *

Dept. of ECE, Sree Buddha College of Engineering

53

08.607 Microcontroller Lab Manual

P'"8'a2) S01a'& "/ a $12+&' M&2"'6 a;;'&-H&7. 9";& La+&( A--&2+(6 C";&C"22&$ -

I$,1 )
M&2"'6 4200 Da a

O1 ,1 )
M&2"'6 4500 4501 Da a upper byte Lower byte

P'"8'a2) S01a'& '"" "/ a ,&'/&9 -01a'& $12+&' M&2"'6 a;;'&-H&7. 9";& La+&( A--&2+(6 C";&C"22&$ -

I$,1 )
M&2"'6 Da a

O1 ,1 )
M&2"'6 Da a

Dept. of ECE, Sree Buddha College of Engineering

54

08.607 Microcontroller Lab Manual

4200

Data

4500

R&-1( ) /hus an assembly language programs were written to find the s uare and s uare root of a gi!en number and it was e"ecuted successfully

R&/&'&$9&) /he 4+8* 'icrocontroller and Embedded Systems & 'uhammad Ali 'a$idi, Ranice Dillispie 'a$idi.

Dept. of ECE, Sree Buddha College of Engineering

55

08.607 Microcontroller Lab Manual

FLO4 CHART) Fi+"$a99i -&'i&- 8&$&'a i"$

Start

#ead the number of 6ibonacci numbers to be generated, Count


Fibonacci number

%ut AU*, BU+

0rite the !alue of A into memory location pointed by the data pointer
SU AEB

AUB and BUS

Increment data pointer

;ecrement Count

C-

Is Cou ntU+ V

TES
Stop

Dept. of ECE, Sree Buddha College of Engineering

56

08.607 Microcontroller Lab Manual

E"p Co = < ;ate =

FIBONACCI SERIES GENERATION


Ai2 /o write and e"ecute an assembly language program to generate afibonacci series of a number and sa!e the output to specified memory location. A,,a'a 1- R&01i'&;) N" * Na2& 'icrocontroller kit @1a$ i 6 *

A(8"'i !2) Fi+"$a99i -&'i&- 8&$&'a i"$ *= Start 3= #ead the number of 6ibonacci numbers to be generated, Count 5= %ut AU+, BU*. 7= 0rite the !alue of A into memory location pointed by the data pointer 8= Add A and B 2= Sa!e the sum := Load with the !alue in B and B with the !alue of sum. 4= Increment data pointer <= ;ecrement count *+= Check whether the Count is e ual to $ero If no, go to step 7. **= Stop

Dept. of ECE, Sree Buddha College of Engineering

57

08.607 Microcontroller Lab Manual

P'"8'a2) Fi+"$a99i -&'i&- 8&$&'a i"$. M&2"'6 a;;'&-H&7. 9";& La+&( A--&2+(6 C";&C"22&$ -

I$,1 )
M&2"'6 4200 Da a

O1 ,1 )
M&2"'6 4201 Da a

R&-1( ) /hus an assembly language program was written to generate the fibonacci series of a gi!en number and it was e"ecuted successfully

R&/&'&$9&) /he 4+8* 'icrocontroller and Embedded Systems & 'uhammad Ali 'a$idi, Ranice Dillispie 'a$idi.

Dept. of ECE, Sree Buddha College of Engineering

58

08.607 Microcontroller Lab Manual

PART B INTERFACING EFPERIMENTS

Dept. of ECE, Sree Buddha College of Engineering

59

08.607 Microcontroller Lab Manual

Ci'91i ;ia8'a2=DAC I$ &'/a9i$8

Dept. of ECE, Sree Buddha College of Engineering

60

08.607 Microcontroller Lab Manual

E"p Co = *+ ;ate =

DAC INTERFACING
Ai2) /o interface a ;AC to the 4+8* and to write and e"ecute assembly language programs to generate a s uare, triangular and saw tooth wa!eforms at ;AC * output A,,a'a 1- R&01i'&;) N" Na2& * 'icrocontroller kit 3 ;AC interface board A(8"'i !2) Square wave *. Start 3. Load data pointer with the port address for ;AC *. 5. Load the accumulator with the !alue ++h and then load it to the e"ternal 'emory location. 7. Call delay. 8. Load the accumulator with the !alue 66h and then load it to the e"ternal memory location. 2. Call delay. Do to step 3. :. Stop A(8"'i !2) Sawtooth wave *. Start 3. Load data pointer with the port address for ;AC *. 5. Load the accumulator with the !alue ++h and then load it to the e"ternal 'emory location. 7. Increment the !alue stored in Acc. and go to step 5. 8. Stop A(8"'i !2) triangular wave @1a$ i 6 * *

Dept. of ECE, Sree Buddha College of Engineering

61

08.607 Microcontroller Lab Manual

*. Start 3. Load data pointer with the port address for ;AC *. 5. Load the accumulator with the !alue ++h and then load it to the e"ternal 'emory location. 7. Increment the !alue stored in Acc. and go to step 5 till AccY++h. 8. Load the accumulator with the !alue 66h and then load it to the e"ternal memory location. 2. ;ecrement the !alue in Acc. and go to step 8 till Acc.Y++h :. Do to step 5 4. Stop P'"8'a2) DAC i$ &'/a9i$8. S01a'& <av& 8&$&'a i"$ M&2"'6 a;;'&-H&7. 9";& La+&( A--&2+(6 C";&-#D 7*++ '-B ;%/#, I66C+ '-B A, I++ '-BH J;%/#, A LCALL ;ELAT '-B A, I66 '-BH J;%/#, A LCALL ;ELAT LR'% S/A#/ C"22&$ -

S/A#/=

'-B #*, I+8 '-B #3, I66 ;RCZ #3, 9E#E ;RCZ #*, L--% #E/ SR'% S/A#/ Sa< "" ! <av& /"'2 8&$&'a i"$ M&2"'6 a;;'&-H&7. 9";& La+&( A--&2+(6 C";&C"22&$ -

;ELAT = L--%= 9E#E=

-#D 7*++ '-B ;%/#, I66C+ '-B A, I++ L--%= '-BH J;%/#, A ICC A SR'% L--%

Dept. of ECE, Sree Buddha College of Engineering

62

08.607 Microcontroller Lab Manual

T'ia$81(a' <av& /"'2 8&$&'a i"$ M&2"'6 a;;'&-H&7. 9";& La+&( A--&2+(6 C";&C"22&$ -

-#D 7*++ '-B ;%/#, I66C+ S/A#/= '-B A, I++ L--%*= '-BH J;%/#, A ICC A RCZ L--%* '-B A,I66 L--%3= '-BH J;%/#,A ;EC A RCZ L--%3 LR'% S/A#/

P'"9&;1'&) *. Enter the abo!e opcodes from 7*++. 3. E"ecute the program. 5. Check different wa!eforms using C#-. R&-1( ) /hus assembly language programs were written to generate s uare ,triangular and saw tooth wa!eforms at ;AC * output and it was e"ecuted successfully

R&/&'&$9&-) /he 4+8* 'icrocontroller and Embedded Systems & 'uhammad Ali 'a$idi, Ranice Dillispie 'a$idi.

Dept. of ECE, Sree Buddha College of Engineering

63

08.607 Microcontroller Lab Manual

Dept. of ECE, Sree Buddha College of Engineering

64

08.607 Microcontroller Lab Manual

E"p Co = ** ;ate =

STEPPER MOTOR INTERFACING


Ai2) i? ii? /o interface a stepper motor to 4+8* and to write and e"ecute an assembly language program to run stepper motor at different speed. /o rotate stepper motor in forward and re!erse direction.

A,,a'a 1- R&01i'&;) N" * 3 Na2& 'icrocontroller kit Stepper motor Interface card @1a$ i 6 * *

A(8"'i !2) *= Start 3= Load accumulator with the !alue corresponding to 7&step se uence >C49?. 5= Load a count !ariable with a !alue e ual to number of step se uences re uired 7= #otate the accumulator content to right 8= 'o!e the accumulator content to port 2= Call delay := ;ecrement the count !ariable 4= Check the count !ariable, If not $ero, go to step 7 <. Call a delay of * second *+= #eload count !ariable **= Load accumulator with C49

Dept. of ECE, Sree Buddha College of Engineering

65

08.607 Microcontroller Lab Manual

*3= #otate the accumulator to left *5= 'o!e accumulator content to port *7= Call delay *8= ;ecrement count !ariable *2= Check the count !ariable, if not $ero, go to step ** *:= Continue indefinitely from the beginning *4= End

P'"8'a2) T" '1$ a - &,,&' 2" "' a ;i//&'&$ -,&&;. M&2"'6 a;;'&-H&7. 9";& La+&( A--&2+(6 C";&C"22&$ -

-#D 7*++9 S/A#/= '-B ;%/#, IL--A.% '-B #+, I+7 R-= '-BH A,J;%/# %.S9 ;%9 %.S9 ;%L '-B ;%/#, I66C+9 '-B #3,I+79 '-B #*,I+69 ;LT*= '-B #5, I+69 ;LT= ;RCZ #5, ;LT ;RCZ #*, ;LT* ;RCZ #3, ;LT* '-BH J;%/#,A %-% ;%L %-% ;%9 ICC ;%/# ;RCZ #+, RSR'% S/A#/ EC; LOOKUP: ;B +<9, +89, +29, +A9

; Forward rotatio

Dept. of ECE, Sree Buddha College of Engineering

66

08.607 Microcontroller Lab Manual

P'"8'a2) T" '1$ !& - &,,&' 2" "' i$ +" ! /"'<a'; a$; '&v&'-& ;i'&9 i"$ M&2"'6 a;;'&-H&7. 9";& La+&( A--&2+(6 C";&-#D 7*++9 '-B #7,IC49 '-B ;%/#,I6-#0A#; LCALL L* ;RCZ #7,L3 LCALL ;ELAT '-B #7,IC49 '-B ;%/#,I#EBE#SE LCALL L* ;RCZ #7,L5 LCALL ;ELAT SR'% S/A#/ '-B #+,I+79 '-BH A,J;%/# %.S9 ;%9 %.S9 ;%L '-B ;%/#,I66C+9 '-B #3,I+79 '-B #*, I+89 '-B #5, I669 ;RCZ #5, L7 ;RCZ #*, L2 ;RCZ #3, L: '-BH J;%/#, A %-% ;%L %-% ;%9 ICC ;%/# ;RCZ #+, L--% C"22&$ -

S/A#/= L3=

L5=

L*= L--%=

L!: L": L4:

Dept. of ECE, Sree Buddha College of Engineering

67

08.607 Microcontroller Lab Manual

#E/ D#L$%: '-B #8, I+*9 L&: '-B #3, I+89 L': ;RCZ #3, L4 ;RCZ #8, L< #E/ FO()$(D: ;B +<9, +89, +29, +A9 (#*#(+#: ;B +A9, +29, +89, +<9

P'"9&;1'&) *. Enter the abo!e opcodes from 7*++. 3. E"ecute the program. 5. Connect 'otor in %7 Connector. 'otor is rotate in a gi!en direction at gi!en angle.

R&-1( ) /hus an assembly language programs were written to rotate stepper motor in different direction at different angle and at different speed and it was e"ecuted successfully

R&/&'&$9&-) /he 4+8* 'icrocontroller and Embedded Systems & 'uhammad Ali 'a$idi, Ranice Dillispie 'a$idi.

Dept. of ECE, Sree Buddha College of Engineering

68

08.607 Microcontroller Lab Manual

Ci'91i ;ia8'a2) I$ &'/a9i$8 <i ! 8 +i ADC

Dept. of ECE, Sree Buddha College of Engineering

69

08.607 Microcontroller Lab Manual

E"p Co = *3 ;ate =

INTERFACING 4ITH 8=BIT ADC


Ai2) /o interface an A;C +4+< to the 4+8* and to write and e"ecute an assembly language program to con!ert the analog input at channel + to a digital !alue. A,,a'a 1- R&01i'&;) N" * 3 T!&"'6)
Connect the A;C+4+< to the 4+8* and write a program to see the corresponding digital !alue in the LE; display. %rogram selects channel +.Start the analog to digital con!ersion process by pressing S-C switch. A;C +4+< con!erts the analog input at channel + to a digital !alue and :7LS5:7 latachet the data to glow the LE;s accordingly.

Na2& 'icrocontroller kit A;C Interface card

@1a$ i 6 * *

A(8"'i !2)
*= Start 3= Assign : bits of a port to ALE, -E, SC, E-C signals and to analog channel selection signals, namely A, B, C. 5= Select an analog channel. 7= Acti!ate the ALE pin >address latch enable( L&to&9 pulse?. 8= Acti!ate SC >start of con!ersion( L&to&9 pulse? 2= 'onitor E-C >end of con!ersion( if con!ersion o!er and data is ready to be picked up, 9& to&L output? := Acti!ate -E >output enable? to read data out of the A;C chip. 4= Con!ert the 9EH data to ASCII and pass the characters to display on to LE; <= Stop

P'"8'a2) I$ &'/a9i$8 <i ! 8=+i ADC

Dept. of ECE, Sree Buddha College of Engineering

70

08.607 Microcontroller Lab Manual

M&2"'6 a;;'&--

H&7. 9";&

La+&(

A--&2+(6 C";&-#D 7*++ '-B ;%/#, I66C4 '-B A,I*+ '-BH J;%/#,A '-B A,I*4 '-BH J;%/#,A SR'% 9L/

C"22&$ -

;,H$--#L 0 +#L#,./O;$-D $L# LO) ; $L# H/0H

9L/=

P'"9&;1'&) *.%lace )umper R3 in B position. 3. %lace )umper R8 in A position. 5. Enter the abo!e opcodes from 7*++. 7. E"ecute the program. 8. Bary the analog input>using trimpot? and gi!e the S-C by pressing the S-C switch. 2. See the corresponding digital !alue in the LE; display. R&-1( ) /hus an assembly language programs was written to con!ert the analog input at
channel + to a digital !alue and it was e"ecuted successfully.

R&/&'&$9&-) /he 4+8* 'icrocontroller and Embedded Systems & 'uhammad Ali 'a$idi, Ranice Dillispie 'a$idi.

Dept. of ECE, Sree Buddha College of Engineering

71

08.607 Microcontroller Lab Manual

Ci'91i ;ia8'a2= LCD ;i-,(a6

Dept. of ECE, Sree Buddha College of Engineering

72

08.607 Microcontroller Lab Manual

E"p Co = *5 ;ate =

DISPLA5 INTERFACING
Ai2) /o interface a LC; to the 4+8* and to write and e"ecute an assembly language program to display some te"t on LC;. A,,a'a 1- R&01i'&;) N" * 3 Na2& 'icrocontroller kit LC; Interface card @1a$ i 6 * *

A(8"'i !2)
*= Start 3= Initiali$e the LC; 3 lines, 8 H : matri" 5= Start the command mode 7= %ass command for display on and cursor on to the LC; 8= %ass command to clear LC; 2= %ass command to shift cursor right := Enter in display mode for LC; 4= %ass the characters to display on to LC; <= Stop

Dept. of ECE, Sree Buddha College of Engineering

73

08.607 Microcontroller Lab Manual

P'"8'a2) T" ;i-,(a6 &7 G CI MICROS5STEMSG "$ LCD. M&2"'6 a;;'&-H&7. 9";& La+&( A--&2+(6 C";&-#D 7*++9 LA/C9 EQ. +66+49 ;EC EQ. +66+79 ;ECL EQ. +79 LA/C9L EQ. -49 I-9ID9 EQ. +669 LCALL B.STC9ECA '-B ;%/#,I;EC '-B A,I549 '-BH J;%/#,A LCALL B.STC9ECA '-B A,I+*9 '-BH J;%/#,A LCALL B.STC9ECA '-B A,I+29 '-BH J;%/#,A LCALL B.STC9ECA '-B A,I+69 '-BH J;%/#,A LCALL B.STC9ECA '-B A,I4+9 '-BH J;%/#,A '-B ;%/#,IL--A.% '-B #3,I+69 LCALL B.STC9ECA '-BA,I+* '-B %3,II-9ID9 '-BH J#+,A '-BH A,J;%/# '-B %3,II-9ID9 '-BH J#*,A ICC ;%/# ;RCZ #3,'-#E SR'% 9L/ '-B #*,I;ECL '-B #+,ILA/C9L '-B %3,II-9ID9 '-B A,I+3

C"22&$ -

S/A#/=

(/- 6.CC/I-C SE/ ( CLEA# ;IS%LAT (EC/#T '-;E SE/ (;IS%LAT /9E C.#-# -C

'-#E=

9L/ B.STC9ECA

Dept. of ECE, Sree Buddha College of Engineering

74

08.607 Microcontroller Lab Manual

BST=

L--A.%=

'-BH J#+,A '-B %3,II-9ID9 '-BH A,J#* ACL A,I4+9 RCZ BST '-B %3,II-9ID9 '-B A,I++ '-BH J#+, A #E/ ;B SBI 'IC#-STS/E'S

L"":=1, Ta+(&)
M&2"'6 7*83 7*82 7*8A 7*8E H&7. 9";&
5" 4& 20 4D 4& 43 52 4F 53 5& 53 54 45 4D 53 20

P'"9&;1'&) *. Enter the abo!e opcodes from 7*++. 3. E"ecute the program. 5. See output in LC;. KBI 'IC#-STS/E'S K is displayed. R&-1( ) /hus an assembly language programs was written to display some te"t on LC; and it was e"ecuted successfully. R&/&'&$9&-) /he 4+8* 'icrocontroller and Embedded Systems & 'uhammad Ali 'a$idi, Ranice Dillispie 'a$idi.

Dept. of ECE, Sree Buddha College of Engineering

75

08.607 Microcontroller Lab Manual

Ci'91i ;ia8'a2=<av&/"'2 8&$&'a i"$

G&$&'a i$8 L"": 1, a+(& BoutU 8B E >8BX sin [? ;AC input !alueU Bout X 38.2 0here [ !aries between + and 52+ degrees.

Dept. of ECE, Sree Buddha College of Engineering

76

08.607 Microcontroller Lab Manual

E"p Co = *7 ;ate =

4ACEFORM GENERATION USING LOO3UP TABLES


Ai2) /o interface a ;AC to the 4+8* and to write and e"ecute an assembly language program to generate a sine wa!eform at ;AC * output A,,a'a 1- R&01i'&;) N" Na2& * 'icrocontroller kit 3 ;AC interface board A(8"'i !2) *= Start 3= %repare the look up table and store the !alues in consecuti!e memory locations 5= Initiali$e #5 with the number of elements in the look up table 7=Load #* and #3 with lower and higher bytes of starting address of look up table. 8. Load the data pointer with the !alues in #* and #3 respecti!ely. 2= Load the !alue written in the memory location to Accumulator. := -utput that !alue through an output port 4= Increment #*. <= ;ecrement #5 and check whether it is $ero, If not go to step8. *+= Do to step 5 **= Stop P'"8'a2) 4av&/"'2 8&$&'a i"$ 1-i$8 ("":1, a+(&-. M&2"'6 a;;'&-H&7. 9";& La+&( A--&2+(6 C";&-#D 7*++ '-B #*,I++ C"22&$ @1a$ i 6 * *

Dept. of ECE, Sree Buddha College of Engineering

77

08.607 Microcontroller Lab Manual

S/A#/= L--%=

'-B #3,I73 '-B #5,I72 '-B ;%L,#* '-B ;%9,#3 '-BH A,J;%/# '-B ;%/#,I66C+ '-BH J;%/#,A ICC #* ;RCZ #5,L--% LR'% S/A#/

(Count

( ;AC * output

L"":=1, a+(&) M&2"'6 a;;'&-73++ 73+7 73+4 73+C 73*+ 73*7 73*4 73*C 733+ 7337 7334 733C 735+ 7357 7354 735C 737+ 7377 P'"9&;1'&) *. Enter the abo!e opcodes from 7*++. 3. E"ecute the program. 5. Check sine wa!e using C#-. R&-1( ) /hus an assembly language programs was written to generate a sine wa!eform at ;AC * output and it was e"ecuted successfully. :6 AA ;* E; 6C 6C E; ;* AA :6 85 3; *+ +* +: *; 56 2< H&7. C";& 4A B8 ;< 63 6E 6A E: C4 A+ :7 7< 38 +B ++ +B 38 7< :7 <8 B6 E+ 6: 66 6: E+ B6 <8 2< 56 *; +: +* *+ 3; 85 A+ C4 E: 6A 6E 63 ;< B8 4A 86 52 *: +7 +7 *: 52 86

Dept. of ECE, Sree Buddha College of Engineering

78

08.607 Microcontroller Lab Manual

R&/&'&$9&-) /he 4+8* 'icrocontroller and Embedded Systems & 'uhammad Ali 'a$idi, Ranice Dillispie 'a$idi.

E"p Co = *8 ;ate =

P4M GENERATION
Ai2) /o generate a pulse width modulation signal. A,,a'a 1- R&01i'&;) N" Na2& @1a$ i 6 * * 'icrocontroller kit T!&"'6)

%ulse width modulation is a commonly used techni ue for controlling power to inertial electrical de!ices, made practical by modem electronic power switches. /he a!erage !alue of !oltage >and current? fed to the load is controlled by turning the switches between supply and load on and off at a fast pace. /he longer switch is on compared to the off periods, the higher the power supplied to the load is. /he %0' switching fre uency has to be much faster than what would affect the load, which is to be stay the de!ice that uses the power. /he term duty cycles describes the proportion of Son S time to the regular inter!al or Speriod of time( a low duty cycle corresponds to low power , because the power is off for most of the time. ;uty cycle is e"pressed in percent,*++@ being fully on. /he main ad!antage of %0' is that the power loss in the switching de!ices is !ery low. 0hen a switch is off there is practically no current, and when it is on ,there is almost no !oltage drop across the switch.%wer loss being the product of !oltage and current, is thus in both cases close to $ero. %0' works also well with digital controls, which, because of their on,off nature, can easily set the needed duty cycle. In 4<C8*#;3 ha!e *2 bit compare module. Each mode can be programmed to operate one of the four mode. *. #ising and,or falling edge capture 3. Software timer 5. 9igh speed output

Dept. of ECE, Sree Buddha College of Engineering

79

08.607 Microcontroller Lab Manual

7. %ulse width modulation %*.5 to %*.: are the those fi!e pins. 6irst we set these pins as %0' mode. ;uty cycle of %0' is automatically change +@ to *++@. %0' + & %*.5 %0' * & %*.7 %0' 7 & %I.: %0' 3 & %*.8 %0' 5 & %*.2 CCA%n9 U 382 >*&;uty cycle?.

A(8"'i !2) *= Start 3= 'ake a port in >say p*.+?as high. 5= Store an immediate !alue of 66h in register #*. 7= Check #*U+.If, no ,proceed, otherwise go to step 2. 8= Call the delay loop inside which the #* !alue will decrement.Do to step 7. 2=Complement the port pin %*.+. :=Store the register #* with the immediate !alue>*++&A? 4= Do to step 7. Step <= Stop. P'"8'a2) P4M0. M&2"'6 a;;'&-H&7. 9";& La+&( A--&2+(6 C";&-#D 7*++9 1O* ,1OD2302H 1O* ,L2300H 1O* ,H2300H 1O* ,,$P102342H 1O* ,,$P0L2300H L1:
1O* (1230FFH 1O* ,,$P0H2(1 ,$LL D#L$% 1O* ,,O-2340H D4-5 (12L1 1O* (2230FFH 1O* (3230FFH

C"22&$ -

D#L$%: L5=

Dept. of ECE, Sree Buddha College of Engineering

80

08.607 Microcontroller Lab Manual

L3=

D4-5 (32L2 D4-5 (22L3 (#.

EC;

P'"9&;1'&) *. Enter the abo!e opcodes from 7*++. 3. E"ecute the program. 5. Connect %*: M %*2 9eader .sing *+ %in 6#C cable. 7. %0' wa!e is generate in P%* %- PIN.

P'"8'a2) P4M%. M&2"'6 a;;'&-H&7. 9";& La+&( A--&2+(6 C";&-#D 7*++9 1O* ,1OD2302H 1O* ,L2300H 1O* ,H2300H 1O* ,,$P112342H 1O* ,,$P1L2300H L1:
1O* (1230FFH 1O* ,,$P1H2(1 ,$LL D#L$% 1O* ,,O-2340H D4-5 (12L1 1O* (2230FFH 1O* (3230FFH D4-5 (32L2 D4-5 (22L3 (#.

C"22&$ -

D#L$%: L5= L3=

EC;

P'"9&;1'&) *. Enter the abo!e opcodes from 7*++. 3. E"ecute the program. 5. Connect %*: M %*2 9eader .sing *+ %in 6#C cable. 7. %0' wa!e is generate in P%* *$; PIN.

R&-1( ) /hus an assembly language programs were written to generate a pulse width modulation signal and it was e"ecuted successfully.

Dept. of ECE, Sree Buddha College of Engineering

81

08.607 Microcontroller Lab Manual

R&/&'&$9&-) /he 4+8* 'icrocontroller and Embedded Systems & 'uhammad Ali 'a$idi, Ranice Dillispie 'a$idi.

Ci'91i ;ia8'a2 =R&a(iHa i"$ "/ B""(&a$ &7,'&--i"$

A, B, C, ; are the input to this e uation S0*8 & A S0*7 & B S0*5 & C S0*3 \ ; Di!en input data also display in LE;.

Dept. of ECE, Sree Buddha College of Engineering

82

08.607 Microcontroller Lab Manual

E"p Co = *2 ;ate =

REALIIATION OF BOOLEAN EFPRESSION USING PORT


Ai2) /o write and e"ecute an assembly language program to reali$e Boolean e"pression, by taking the state of Boolean !ariables using ports. TU AB!"#. A,,a'a 1- R&01i'&;) N" Na2& * 'icrocontroller kit A(8"'i !2) *= Start 3= Initiali$e four port pins as input ports. 5= Sa!e state of first port pin p*.+ to Carry flag >CT?. 7= AC; status of port pin p*.* with carry and sa!e status of CT to p3.+. 8= Sa!e state of port pin p*.3 to Carry flag >CT?. AC; p*.5 to CT. 2= Sa!e state of CT to p3.* and sa!e state of p3.+ to CT. := -# CT with status of p3.* and sa!e state of CT to p3.5. 4= Stop. P'"8'a2) @1a$ i 6 *

Dept. of ECE, Sree Buddha College of Engineering

83

08.607 Microcontroller Lab Manual

M&2"'6 a;;'&--

H&7. 9";&

La+&(

A--&2+(6 C";&-

C"22&$ -

'-B %3, I++9 S/A#/= '-B C, %*.+ ACL C, %*.* '-B %3.+, C '-B C, %*.3 ACL C, %*.5 '-B %3.*, C '-B C, %3.+ -#L C, %3.* '-B %3.5, C SR'% S/A#/ 9L/= SR'% 9L/ P'"9&;1'&) If Input A is high LE; *2 -C Input A is low LE; *2 -66

Input B is high LE; *8 -C Input B is low LE; *8 -66 /he first KAC;L gate output either high or low. /his is shown in LE; *7. Input C is high Input C is low Input ; is high Input ; is low LE; *5 -C LE; *5 -66 LE; *3 -C LE; *3 -66

/his second AC; gate output either high or low. If is shown in LE; **. /he final output T is high means LE; < is -C otherwise LE; < is -66. R&-1( ) /hus an assembly language program was written to reali$e the gi!en Boolean e"pression and it was e"ecuted successfully R&/&'&$9&-) /he 4+8* 'icrocontroller and Embedded Systems & 'uhammad Ali 'a$idi, Ranice Dillispie 'a$idi.

Dept. of ECE, Sree Buddha College of Engineering

84

08.607 Microcontroller Lab Manual

E"p Co = *: ;ate =

FRE@UENC5 MEASUREMENT B5 COUNTING THE NUMBER OF PULSES IN A FIFED AMOUNT OF TIME


Ai2) /o measure the fre uency of a pulse by measuring the number of pulses in a fi"ed amount of time. A,,a'a 1- R&01i'&;) N" Na2& @1a$ i 6 * * 'icrocontroller kit T!&"'6)

/his program is measure fre uency of gi!en input in a particular time. 6or that we initiali$e timer + for *ms delay. And also we initiali$e %CA timer interrupt. 0hen %CA interrupt is come the timer + is turn -C and count the number of rising edge will come. 0hen timer + interrupt is come the %CA timer M timer + is turn off and calculate fre uency of a gi!en input in that time. Cote= In this program we set *ms delay. So at least gi!en fre uency of is 3 k9$. So only the counts will 3. Ca(91(a i"$) %CA clock input U *3,**.+48< '9$ U *.+4386s Initiali$e timer !alue U * k9$ and enable timer + o!erflow interrupt. Input fre uency is *+ A9$. If count !alue U 3 /otal count U 3 ] *+ U 3+

Dept. of ECE, Sree Buddha College of Engineering

85

08.607 Microcontroller Lab Manual

0e set timer + !alue in *ms delay. After that it will generate interrupt .

A(8"'i !2) *. initiali$e timer + for *ms delay 3. initiali$e serial port and %CA timer interrupt 5. Clear CC6+. If flag not set means to increment count !alue, otherwise to enable to timer interrupt 7. ;isable capture interrupt and timer interrupt. 8. Initiali$e timer !alue and enable capture interrupt 2. Calculate fre uency of a gi!en input in that time. P'"8'a2) F'&01&$96 2&a-1'&2&$ +6 9"1$ i$8 !& $12+&' "/ ,1(-&- i$ a /i7&; a2"1$ "/ i2&.
M&2"'6 a;;'&-H&7. 9";& La+&( A--&2+(6 C";&-#D *+++9 CALL SE#IAL CALL /I'E#+NICI/ CALL %CANICI/ '-B SB.6,IFAF RCB /I,^ LCALL ;ELAT CL# /I SR'% L* '-B C'-;, I++9 '-B C9, I++9 '-B CL, I++9 '-B CCA%'+, I3*9 SE/B EC SE/B EA CL# 6LAD #E/ '-B /'-;,I3+9 '-B /9* ,I+6;9 '-B SC-C,I839 SE/B /#* #E/ SE/B /#+ '-B A,/'-; -#L A,I+*9 '-B /'-;,A C"22&$ -

L*= %CANICI/=

( Initiali$e %CA timer

SE#IAL=

(to initiali$e serial port

(SE/B /I (to initiali$e /imer

/I'E#+NICI/=

Dept. of ECE, Sree Buddha College of Engineering

86

08.607 Microcontroller Lab Manual

;ELAT= L-%8= L-%7=

'-B /9+,I+6C9 '-B /L+,I749 '-B IE,I4+9 #E/ '-B 7+9,I+*9 '-B 7*9,I+69 ;RCZ 7*9,L-%7 ;RCZ 7+9,L-%8 #E/ -#D ++559 CL# CC6+ RB 6LAD,D-* SE/B E/+ SE/B 6LAD ICC #5 #E/I -#D +++B9 CL# EC CL# E/+ CL# 6LAD '-B /9+,I+6C9 '-B /L+,I749 SE/B EC '-B A,#5 '-B B,I*+9 '.L AB '-B SB.6,A RCB /I,^ LCALL ;ELAT CL# /I '-B #5,I++9 #E/I

(%CA IC/E##.%/ ( if flag not set means to increment count !alue (otherwise to enable to timer interrupt

D-*=

(/I'E# IC/E##.%/ (disable capture interrupt (disable /imer interrupt (initiali$e timer !alue (2: (enable capture interrupt

P'"9&;1'&) *. Enter the abo!e opcodes from 7*++. 3. E"ecute the program. 5. In serial window the fre uency !alue is shown in A9$. R&-1( ) /hus an assembly language programs was written to measure the fre uency of a pulse by measuring the number of pulses in a fi"ed amount of time and it was e"ecuted successfully. R&/&'&$9&-) /he 4+8* 'icrocontroller and Embedded Systems & 'uhammad Ali 'a$idi, Ranice Dillispie 'a$idi.

Dept. of ECE, Sree Buddha College of Engineering

87

08.607 Microcontroller Lab Manual

E"p Co = *4 ;ate =

FRE@UENC5 MEASUREMENT B5 MEASURING THE TIME PERIOD BET4EEN T4O CONSECUTICE PULSES
Ai2) /o write and e"ecute an assembly language program to measure the fre uency of a pulse by measuring the time period between two consecuti!e pulses. A,,a'a 1- R&01i'&;) N" * T!&"'6) /his program is measure fre uency of two connecti!e pulse first we initiali$e %CA interrupt for rising edge detection. 0hen rising edge is detect the %CA timer is -C and then falling edge is detect the timer is run between rising edge to falling edge detect. .sing %CA timer count we calculate fre uency of the gi!en signal. E7a2,(& Ca(91(a i"$ 6re uency U**.+8< '9Z %CA clock input U>*,*3 ? X6-SC Na2& 'icrocontroller kit @1a$ i 6 *

Dept. of ECE, Sree Buddha College of Engineering

88

08.607 Microcontroller Lab Manual

%CA clock input U>*3,**.+48< ? U*.+438 _s /ake count !alue from CL M C9. If total count is +]:;. ;ecimal !alue is *38. /ime U Count X*.+438 _s U*38X*.+438 _s U*58.5*38 _s 6re uency U*,/ U*,>*58.5*38X*+&2 ? U*+2,*58.5*38 U+.++:5<+5X*+2 U:.5<+5 A9Z A(8"'i !2) *= Start 3= Set timer * as timer in mode * 5= 'ake one port pin as input port 7. Initiali$e %CA timer for rising edge detection 7= 0hen rising edge is detect the %CA timer is -C and then falling edge is detect the timer is run between rising edge to falling edge detect. 8= %CA timer count is used to calculate fre uency of the gi!en signal 2. Stop. P'"8'a2) F'&01&$96 2&a-1'&2&$ +6 2&a-1'i$8 !& i2& ,&'i"; +& <&&$ <" 9"$-&91 iv& ,1(-&M&2"'6 a;;'&-H&7. 9";& La+&( A--&2+(6 C";&-#D ++559 41P P,$7/-.#((UP. O(0 1000H ,$LL P,$7/-/. ,$LL +#(/$L ,$LL +#-D +41P L1 %CANICI/= 1O* ,1OD2 300H 1O* ,H2 300H 1O* ,L2 300H '-B CCA%'+, I3*9 +#.< #, SE/B EA SE/B C# CL# 6LAD #E/ CL# CC6+ RB 6LAD, SEC-C;NCA%/.#E '-B CL ,I++9 '-B C9 ,I++9 '-B CCA%'+, I**9 SE/B 6LAD #E/I ,L( , 1O* $2 ,L 1O* (22$ 1O* $2 ,H 1O* (32$ 1O* ,,$P102 321H ; / itia9i:e P,$ ti;er C"22&$ -

L1:

;,$LL +#-D1 ;8a99 8a98

P,$7/-.#((UP.: F/(+.7,$P.U(#:

;,L( ,( ;F$LL/-0 #D0#

+#,O-D7,$P.U(#:

;(/+/0/-0 #D0#

Dept. of ECE, Sree Buddha College of Engineering

89

08.607 Microcontroller Lab Manual

,$L,:

+#-D:

D#L$%: LOP5: LOP4:

+#(/$L:

,L( FL$0 (#./ 1O* $2(2 1O* <2302H 1UL $< 1O* $2311H D/* $< 1O* $2(2 (#. 1O* +<UF23=$= 4-< ./2> L,$LL D#L$% ,L( ./ 1O* +<UF2(3 4-< ./2> L,$LL D#L$% ,L( ./ 1O* +<UF2(2 4-< ./2> L,$LL D#L$% ,L( ./ (#. 1O* 40H23!FH 1O* 41H230FFH D4-5 41H2LOP4 D4-5 40H2LOP5 (#. 1O* .1OD2320H 1O* .H1 230FDH 1O* +,O-2352H +#.< .(1 (#.

;H/0H#( <%.# *$LU#+

;LO)#( <%.# *$LU#+

P'"9&;1'&) *. Enter the abo!e opcodes from 7*++. 3. E"ecute the program. 5. /he gi!en 6re uency !alue is display in serial window in A9$. R&-1( ) /hus an assembly language programs was written to measure the fre uency of a pulse by measuring the time period between two consecuti!e pulses and it was e"ecuted successfully. R&/&'&$9&-) /he 4+8* 'icrocontroller and Embedded Systems & 'uhammad Ali 'a$idi, Ranice Dillispie 'a$idi.

Dept. of ECE, Sree Buddha College of Engineering

90

08.607 Microcontroller Lab Manual

E"p Co = *< ;ate =

LED BLIN3ING USING EMBEDDED C PROGRAMMING


Ai2) /o write and e"ecute a c program to blink LE;. A,,a'a 1- R&01i'&;) N" * Na2& 'icrocontroller kit @1a$ i 6 *

P'"8'a2
IincludeOreg8*.hP IincludeOstdio.hP "data char Xledsel( int i,!al( !oid delay>? ` int i,)( for>iU+(iO+"ff(iEE? for>)U+()O+"ff()EE?( a !oid main>? `

Dept. of ECE, Sree Buddha College of Engineering

91

08.607 Microcontroller Lab Manual

ledsel U +"ff35( while>*? ` for>iU+(iO8(iEE? ` Xledsel U delay>?( Xledsel U delay>?( a for>iU+(iO8(iEE? ` Xledsel U delay>?( Xledsel U delay>?( a a a

+"++( +"ff(

+"88( +"aa(

R&-1( ) /hus a c language program was written to blink LE; and it was e"ecuted successfully. R&/&'&$9&-) /he 4+8* 'icrocontroller and Embedded Systems & 'uhammad Ali 'a$idi, Ranice Dillispie 'a$idi.

Dept. of ECE, Sree Buddha College of Engineering

92

08.607 Microcontroller Lab Manual

E"p Co = 3+ ;ate =

ADC INTERFACING USING EMBEDDED


analog input at channel + to a digital !alue.

C PROGRAMMING

Ai2) /o interface an A;C +4+< to the 4+8* and to write and e"ecute a c program to con!ert the A,,a'a 1- R&01i'&;) N" * Na2& 'icrocontroller kit @1a$ i 6 *

P'"8'a2
IincludeOreg8*.hP IincludeOstring.hP IincludeOstdio.hP ,,%rototype ;eclaration !oid I3CN0#I/E>unsigned char?( !oid ;ataN0rite>unsigned char bc,unsigned int?( unsigned char I3CN#EA;>?( !oid ;elayN/ime>?( !oid busycheck>?( !oid I3CNS/A#/>?(

Dept. of ECE, Sree Buddha College of Engineering

93

08.607 Microcontroller Lab Manual

!oid I3CNS/-%>? ( !oid lcdint>?( !oid serNint>?( unsigned int #EA;( sbit SCLAU%5d3( sbit S;A U%5d5( bit ACA( Idefine 9ID9 +*( Idefine L-0 ++( idata unsigned char dat( idata unsigned char i( unsigned int adcNdata( !oid main>? ` serNint>?( I3CNS/A#/>?( I3CN0#I/E>+H<e?( I3CN0#I/E>+H7*?( while>*?` I3CNS/A#/>?( I3CN0#I/E>+"<f?( adcNdata U I3CN#EA;>?( printf>Gener Adc ;ata =@"G,adcNdata?( I3CNS/-%>?( I3CNS/A#/>?( I3CN0#I/E>+"<f?( adcNdata U I3CN#EA;>?( I3CNS/-%>?( a a !oid serNint>? ` /'-; U +H3+( /9* U +H6;( /#* U *( /I U *( a !oid I3CNS/A#/>? ` SCLA UL-0( S;A UL-0(

Dept. of ECE, Sree Buddha College of Engineering

94

08.607 Microcontroller Lab Manual

;elayN/ime>?( ;elayN/ime>?( SCLAU9ID9( ;elayN/ime>?( ;elayN/ime>?( S;AU9ID9( ;elayN/ime>?( ;elayN/ime>?( S;AUL-0( ;elayN/ime>?( ;elayN/ime>?( SCLAUL-0( a !oid I3CN0#I/E>unsigned char )? ` datU)( for>iU+(iO4(iEE? ` S;A U dat M +"4+( datUdatOO*( SCLAU9ID9( ;elayN/ime>?( ;elayN/ime>?( SCLA U L-0( a S;AU9ID9( ;elayN/ime>?( ;elayN/ime>?( SCLA U 9ID9( ;elayN/ime>?( ;elayN/ime>?( ACA U S;A( ;elayN/ime>?( ;elayN/ime>?( SCLAUL-0( a !oid I3CNS/-%>? ` SCLAUL-0( ;elayN/ime>?( ;elayN/ime>?( S;AU9ID9( a

Dept. of ECE, Sree Buddha College of Engineering

95

08.607 Microcontroller Lab Manual

unsigned char I3CN#EA;>? ` unsigned char i,)( )U+( )US;A( for>iU+(iO4(iEE? ` )OOU*( SCLAU9ID9( )fUS;A( ;elayN/ime>?( SCLAUL-0( a ;elayN/ime>?( ;elayN/ime>?( S;A U L-0( ;elayN/ime>?( ;elayN/ime>?( SCLA U 9ID9( ;elayN/ime>?( ;elayN/ime>?( SCLA U L-0( ;elayN/ime>?( ;elayN/ime>?( S;A U 9ID9( return>)?( a !oid ;elayN/ime>? ` unsigned long int i( for>iU+(iO8++(iEE?( a

R&-1( ) /hus a c language program was written to interface an A;C +4+< to the 4+8* and it was e"ecuted successfully. R&/&'&$9&-) /he 4+8* 'icrocontroller and Embedded Systems & 'uhammad Ali 'a$idi, Ranice Dillispie 'a$idi.

Dept. of ECE, Sree Buddha College of Engineering

96

08.607 Microcontroller Lab Manual

E"p Co = 3* ;ate =

STEPPER MOTOR INTERFACING USING EMBEDDED C PROGRAMMING


Ai2) /o interface stepper motor to the 4+8* and to write and e"ecute a c program to rotate stepper motor in a clockwise and anti clockwise direction. A,,a'a 1- R&01i'&;) N" * P'"8'a2 Iinclude OIntel,4+8*.hP Idefine p4388Nctl +"3+75 Idefine portc +"3+73 Idefine ctlrNword +"4+ ,, for clockwise phasea is +d, phaseb is +e, phasec is +: and phased is +b ,, for anti clockwise phasea is +b, phaseb is +:, phasec is +e and phased is +d Idefine phasea +"+d Idefine phaseb +"+e Idefine phasec +"+: Idefine phased +"+b Na2& 'icrocontroller kit @1a$ i 6 *

Dept. of ECE, Sree Buddha College of Engineering

97

08.607 Microcontroller Lab Manual

"data unsigned char XptrN4388Nctl( "data unsigned char XptrN4388Nportc( !oid delay>!oid?( !oid main >? ` int i( ptrN4388Nctl U p4388Nctl( XptrN4388Nctl U ctlrNword( while>*? ` ptrN4388NportcUportc( ,,porta address is taken in pointer !ariable ,,different speeds are loaded into pointer XptrN4388Nportc U phasea( delay>?( XptrN4388Nportc U phaseb( delay>?( XptrN4388Nportc U phasec( delay>?( XptrN4388Nportc U phased( delay>?( a a !oid delay>!oid? ` int iU+( for>iU+(iOU*++++(iEE?`a a R&-1( ) /hus a c language program was written to interface stepper motor to the 4+8* and it was e"ecuted successfully. R&/&'&$9&-) /he 4+8* 'icrocontroller and Embedded Systems & 'uhammad Ali 'a$idi, Ranice Dillispie 'a$idi.

Dept. of ECE, Sree Buddha College of Engineering

98

08.607 Microcontroller Lab Manual

Civa=v"9& 01&- i"$*. /he internal #A' memory of the 4+8* is= 3. /he 4+8* has NNNNNNNN *2&bit counter,timers. 5./he 4+8* can handle how many interrupt sourcesV 7. An alternate function of port pin %5.7 in the 4+8* is= 8. /he I,- ports that are used as address and data for e"ternal memory are= 2. /he 4+8* has NNNNNNNN parallel I,- ports. :. /he total e"ternal data memory that can be interfaced to the 4+8* is= 4. Bit&addressable memory locations are= <. /he 4&bit address bus allows access to an address range of= *+. /he number of data registers is= **. 0hat is the difference between the 4+5* and the 4+8*V *3. /he total amount of e"ternal code memory that can be interfaced to the 4+8* is= *5. 0hat are the ad!antages and disad!antages of using 9ar!ard architecture in 4+8*V *7. 9ow much ma"imum e"ternal program memory can be interfacedV *8. 0hat are the power consumptions in power down and idle modes

Dept. of ECE, Sree Buddha College of Engineering

99

08.607 Microcontroller Lab Manual

*2. 0hat is the ma"imum delay the /imer+ produces when 4+8* is operated at *3'9$V *:. E"plain how in Serial communication mode + e"pands I,- lines with the help of shift *4. E"plain Quasi Bidirectional ports of 4+8* *<. 0hat is the status of all registers on resetV 3+. E"plain how in Serial communication mode + e"pands I,- lines with the help of shift 3*. 9ow many bytes are there in the internal memoryV 33. 9ow much program memory is in the chip and how much more can be interfaced e"ternallyV 35. List and e"plain all S6#s . 37. 0hat are the differences between microprocessor and microcontrollerV 38. 0hat address is assigned to register AV 32. 9ow to change register bank in 4+8*V 3:. 0hat is the use of ;RCZ instructionV Di!e the synta". 34.E"plain all the bits in the %S0. .3<. 0hat are the addressing modes in the 4+8*V 5+. 9ow to copy the contents from one memory location to the othersV 5*. 0hat is difference between LCALL and ACALLV 53.0hat is operating fre uency of microcontrollerV 55.0hat is the fre uency of timersV 57.9ow to pro!ide the e"ternal fre uency to the 4+8*V 58.0hat are the modes in which the 4+8* timer worksV 0hich mode you used in your programV 52.9ow to generate the delay using timerV 5:.State the difference between timer and counter. 54.9ow to start the functioning of the timerV 5<.9ow to load the initial count !alues in timersV 7+.State the use of /'-; and /C-C registers in timer programming. 7*.;raw the /'-; and /C-C registers contents. 73. 0hat type of serial communication the 4+8* usesV 75.0hat is baud rateV State standard baud rates. 77..9ow to use the baud rate in 4+8* assembly programV 78.9ow many interrupts are associated with 4+8* serial portsV 72.0hat is the use of %C-C and SB.6 registersV

Dept. of ECE, Sree Buddha College of Engineering

100

08.607 Microcontroller Lab Manual

7:.By which pins the data is transferred and recei!ed serially by 4+8*V 74.;raw the serial data format. 7<.9ow to calculate the bit transmission timeV 8+.9ow to calculate the !alues of /9* and /L* for respecti!e baud ratesV

MICRO CONTROLLER LAB @UESTION BAN3 *. 0rite a program to arrange *+ data stored in 7*++9 onwards in ascending order .Store the result in 77++9. 3. 0rite a program to subtract two *2 bit numbers. 5. 0rite a program to add two *2 bit numbers. 7. Create the following wa!eform and display it on the C#-. 8. -btain the following wa!eform on C#- using suitable assembly language program. 2. Denerate the following wa!eform using an assembly language program. :. A set of non&$ero bytes are stored in locations 7*++9 onwards./he last byte in the data set is indicated by the entry ++9.0rite a program to arrange it in ascending order. 4. 0rite a program to sort *+ numbers stored in memory in the ascending order and get a display of the same with * second delay. <. A set of C numbers are stored in memory location 78++9 onwards.Sort the data in the ascending order and store it in memory location 72++9 onwards.Also find the largest number and display it on the data field.

Dept. of ECE, Sree Buddha College of Engineering

101

08.607 Microcontroller Lab Manual

*+.0rite an assembly program to run the stepper motor such a way that the speed of rotation for clockwise direction must be double of that of the speed for anticlockwise direction. **.0rite an assembly language program to rotate the stepper motor first in clockwise direction for *4++ and then in the anticlockwise direction for the remaining period of rotation. *3.0rite an assembly program to rotate the stepper motor such a way that the speed of rotation for *4+&52++ must be double of that of the speed for +&*4++. *5.0rite an assembly language program to find out largest among the *+ gi!en numbers and display the largest number on the data field. *7.0rite an assembly language program to generate and store the 6ibonacci series. *8.0rite a program to add a few numbers and find its s uare. *2.0rite an AL% to obtain "3E y3, where " and y are two nibbles. *:.0rite a program to find the s uare of a number and display it on the data field. *4.0rite a program to find the s uare root of a number and display it on the data field. *<.0rite a program to add and subtract two *2 bit numbers and store the result on separate memory locations. 3+.6ind SiU Hi,Ti 0here H and T are 4 bit numbers. i is ranging from * to 8. 3*.6ind SiU HiXTi 0here H and T are 4 bit numbers. i is ranging from * to 8. 33.An array of 8 eight bit numbers are stored .6ind the s uare of these numbers and stored it in another array. 35.0rite a program for the addition of two 5X5 matri". 37.0rite a program for the addition of two 7X7 matri". 38.0rite a program to !erify the relation >AEB? 3 U A3E 3ABEB3 ,where A and B are two 4 bit numbers. 32.0rite a program to !erify the relation >A&B? 3 U A3& 3ABEB3 ,where A and B are two 4 bit numbers. 3:.0rite an AL% to display the message ECE3+**. 34.0rite an AL% to e"ecute the following .TU3H E 5, where H and T are 4 bit numbers .;isplay the result on data field. 3<.0rite an AL% to generate a triangular wa!eform of fre uency 3A9Z. 5+.0rite an AL% to generate a saw tooth wa!eform of fre uency 3A9Z. 5*.0rite an AL% to generate a sine wa!eform . 53.0rite an AL% to generate a s uare wa!eform of fre uency 3A9Z. 55.0rite an AL% to multiply two 4 bit numbers by shift and add method. 57.0rite a program to find the product of the largest and smallest among a series of numbers.

Dept. of ECE, Sree Buddha College of Engineering

102

08.607 Microcontroller Lab Manual

58.0rite a program to con!ert analog !oltage to digital !alue and display it on LE;.

Dept. of ECE, Sree Buddha College of Engineering

103

You might also like