0% found this document useful (0 votes)
895 views150 pages

ELTR 363 Microcontroller Controller PDF

This document provides information about microcontrollers and microprocessors. It begins by defining the key differences between microcontrollers and microprocessors. Microcontrollers contain CPU, RAM, ROM and I/O ports integrated on a single chip, while microprocessors only contain the CPU and require external chips for memory and I/O. It then provides a table comparing microcontrollers and microprocessors in more detail on aspects like memory size, speed and functionality. Finally, it lists some short questions related to microcontrollers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
895 views150 pages

ELTR 363 Microcontroller Controller PDF

This document provides information about microcontrollers and microprocessors. It begins by defining the key differences between microcontrollers and microprocessors. Microcontrollers contain CPU, RAM, ROM and I/O ports integrated on a single chip, while microprocessors only contain the CPU and require external chips for memory and I/O. It then provides a table comparing microcontrollers and microprocessors in more detail on aspects like memory size, speed and functionality. Finally, it lists some short questions related to microcontrollers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 150

   


3rd Year

    ‫و‬ ‫ا‬
   300/-


DAE Electronics.
B-Tech Honours in Electronics & Communication.
Electrical Engineering from UMT.
MS Electrical Engineering from LUMS...

Contact: 0333-4296968
ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Chapter 1

Microcontroller Basics



(   )

MS Electrical from LUMS 1


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

1.1 Differentiate between Microcontroller and

Microprocessor

( Microcontroller ) 

 
CPU  
 
( RAM, ROM, EPROM ) 
 
( Watch dog Timer, A/D, D/A )  
 



  

 
 
 I/O ROM RAM *

 
    I/O ROM RAM  *

 
     


 
 
 
( Microprocessor ) 

 
 
CPU  
  

 
 
 
    I/O   ROM   RAM 
   


 

  
    
   

 I/O  ROM RAM


 


   (  ) Bulkier 
        
   
I/O  ROM RAM  
 versatility
Comapre Microcontroller and Microprocessor

Microprocessor Microcontroller

    
    I/O 
         


    

  
  
   

MS Electrical from LUMS 2


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

    
    
  

 
 
   

 
 
  
     
   K   
 
 
   4 G Bytes
   Bytes
128 32,64
   
 
 16  4, 8   
    
    
 
  

 
 1 G Hz    
    10-20 MHz       
  
    
Short Questions

IIA-2013 / IIA_2014 / IIA-2016   



        
IIA_2015  
  
IIA_2015   CISC 

  

 Limitation  
  criteria  

      
 
 

      
 

 
 
 Limitation
  
  
 
   
MCQ's

(c)  

 ( ) 
CPU  ( )

(b) 
  

 (  ) 
 ( )   ( ) 

 ( )

(b)  
 (  ) I/O ( ) ROM ( ) RAM ( )

(a)   


 (  )  ( )  ( )  ( )

(d) 
  
BA (  ) 64
 ( ) 16
 ( ) 8
 ( )

(b)  
  ............ 

MS Electrical from LUMS 3


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

 ( )  
 (  )
(a)  ......... 
  
CISC ( ) RISC (  )

(b) 
   
 
False ( ) True (  )

(a) 
 
  
 I/O ROM RAM  
False ( ) True (  )

1.2 Discuss the Uses of Microcontroller in Industry

and Generl Life

 

 

Short Questions

 Embeded / " Embedded " / embaded 


IA_2013 / 1A_2014/ IIA_2014 / IA-2016 / IIA-2016


  
  /  /   
IIA-2013 / IIA-2015 / IIA-2016

1.3 Describe the Need of Programming Microcontroller




             
 
     
  
 



 
      
   
  




 


MS Electrical from LUMS 4


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

   

 

   
 

 



 ( Assembler, Compiler or Interpreter ) 
  

    

Short Questions

IA_2013 / IA_2015 
   

 
IA_2013 / IIA-2016 
  
  
  
1.4 Discuss the Use of Flow Chart in Programming

1.4.1 Express Different Parts of Flow Chart

( Flow Chart )  

  
    
 
   

  
     
  

 

      

 
    
 
    Decision 

( Terminal )  
   
  
 
( Ovel ) 

  
  
     
  
   
  
 
( Input Output )  
  
   Input/ Output  ( Parallogram ) 
  
 

   Input / Output
 

   
 
   
 

( Process )  
    ( Rectangle ) 
  
 
MS Electrical from LUMS 5
ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

   
    
  

( Sub-Programe )  

 

    
  ( Double line Rectangle )     
 



 
  
  
  Double line Rectangle

( Decision )  
  Decision ( Diamond ) 
  
 

   


    Decision
( Flow Lines )  
   ( Arrow Head Line ) 
  
 

  
  
  

( Connector )  
 
    
    ( Circle with Arrow Head Line )      
  



   
 Connenter
    

 
   
  
 
Short Questions

 
 /  / 
IA_2013/ IIA_2014/ IA_2015 / IIA_2015 / IA-2016 / IIA-2016

IIA_2013 / 1A_2014     /  


 
IA_2015 
  
  
  
  Terminal 
   
  Input/Output 
  
  Process 
   
  Subroutione 
1A_2014    

MS Electrical from LUMS 6


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

  
  Flow Line 
  
  Connector 
MCQ's

(d)  
 ............ 
 
 
  (  )   ( )  ( )   ( )
(a)       
  ...........   
    

 

 (  )  ( )    
 
 ( )  ( )
(c)    ...........   
   

 

 (  )  ( )    
 
 ( )  ( )
(a)  
   


 

 (  )  ( )   

 
 ( )  ( )
(b)  
   


 

 (  )  ( )   

 
 ( )  ( )
(c )  
    


 

 (  )  ( )   

 
 ( )  ( )
(d)  
   


 

 (  )  ( )   

 
 ( )  ( )
(c)  
   


 

 (  ) Decision ( )  
 ( )  ( )

(a)  
   


 

 (  ) Decision ( )  
 ( )  ( )

(b)  
    


 

 (  ) Decision ( )  
 ( )  ( )

MS Electrical from LUMS 7


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968



(b)      

 

 (  ) Decision ( )  
 ( )  ( )
1.4.2 Express Flow of Flow Chart

 
    
   



    

  


  
   


 
  Ovel 
   Process
   

  
    Decision
    


   
   

Decision

  

  
     
     
 Decision  
 
  

   Ovel
   
    
 

MS Electrical from LUMS 8


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

ANSWERS OF THE SHORT QUESTIONS


1.1 Differentiate between Microcontroller and 
Microprocessor

Comapre Microcontroller and Microprocessor

IIA-2013 / IIA_2014 / IIA-2016   


 
CPU  
 
 
( Watch dog Timer, A/D, D/A )   ( RAM, ROM, EPROM ) 



        

IIA_2015  
  
CISC ( Complex Instruction Set Computer )

  


     


RISC ( Reduced Instruction Set Computer )

    


 
      


 access  
 
   

 
IIA_2015   CISC 
   
  CISC  

  
    


  
     
   I/O 
 
   
   
  

 
 
K Bytes  
   
  16 4, 8
  

 
    10-20 MHz 
   

 Limitation  

  

 
 
 I/O ROM RAM
 
   criteria  

MS Electrical from LUMS 9


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968


 criteria 
   
     
    
avalibility 
 resources 

      

 
 
 I/O ROM RAM 

 
Embadded 
 
 
 
 
CPU  
   

 
 
 
    I/O  ROM  RAM 
 

 
 
    
 


      
 


 
 
 
 
 



 
    
   
  
 
   
  
 
 
   4 G Bytes
   
   
 
 128 32,64
  
 
 
 
1 G Hz
  
 
 Limitation
  
  
 I/O  ROM RAM
 


   (   ) Bulkier 

 I/O  ROM RAM    
  versatility 
 
   
Microprocessor Microcontroller

 
 
   
   
   
    
   

  

   


 

MS Electrical from LUMS 10


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

 
    
   
        
  4 G Bytes
   K Bytes

    
1.2 Discuss the Uses of Microcontroller in Industry

and Generl Life

 Embeded / " Embedded " /embaded 


IA_2013 / 1A_2014/ IIA_2014 / IA-2016 / IIA-2016

  
       

  

 embadded
  
 
     
   

  
  /  /   
IIA-2013 / IIA-2015 / IIA-2016


   

 

PC    

 
 
   
1.3 Describe the Need of Programming Microcontroller

IA_2013 / IA_2015 
   
  
  
  
   
 

 

 
 
 
  
   
 
IA_2013 / IIA-2016 
  



 
      
   
  




 

  
  
       

  
 
 


    ( Assembler, Compiler or Interpreter ) 
  

     

1.4 Discuss the Use of Flow Chart in Programming

1.4.1 Express Different Parts of Flow Chart

 
 /  / 
IA_2013/ IIA_2014/ IA_2015 / IIA_2015 / IA-2016 / IIA-2016

MS Electrical from LUMS 11


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

  
    
 
   

IIA_2013 / 1A_2014     /  
 
event 
     Algorithm
   
 
event  event 

 explore  
   
    
  

  
IA_2015 
  
  
  
  
  

 

       
 
    
 
    Decision 
  
  Terminal 
   
  
 
( Ovel ) 

  
  
     
  
   
  
 
   
  Input/Output 
   Input/ Output  ( Parallogram ) 
  
 

   Input / Output
 

   
 
   
 
  
  Process 
    ( Rectangle ) 
  
 

   
    
  
  
  Subroutione 

    
  ( Double line Rectangle )     
 



 
  
  
  Double line Rectangle

1A_2014    
  ( Diamond ) 
   

MS Electrical from LUMS 12


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

  
  Flow Line 
   ( Arrow Head Line ) 
  
 

  
  
 

  
  Connector 
    
    ( Circle with Arrow Head Line )      
  



   


Connenter  
 
 
  
 
  


MS Electrical from LUMS 13


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Chapter 2

Microcontroller Architecture




(    )

MS Electrical from LUMS 14


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

   



 
  
 economical   
  
  
  

 CPU
   I/O Ports   ROM   RAM 

  
 
 
   



 8bit 8051
 
16
Address Bus   
Data Bus  
RAM  128 Byte    4 K
 read only  

   34
  ( SFR ) 
  16 Bit   ALU 
 Dual purpose  I/O  8 Bit
 
  external  internal   
Short Questions

    


 
 
IIA_2015   

 
 
   

 
      RAM8051 
IIA_2014   
  RAM 
IA-2016     
1A_2014  

 24 
IA-2016  

 20 
1A_2014     /     8051 

 8051 
MCQ's

(c)  RAM8051 
 256 (  )  128 ( )  64 ( )  32 (  )
(c ) 8051
 

MS Electrical from LUMS 15


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

 18
 (  )  16
 ( ) 12
 ( ) 8
 (  )

(b) 16 


 
3 (  ) 4 ( ) 2 ( ) 1 (  )

(c)  

 8051 
64 (  ) 32 ( ) 16 ( ) 8 (  )

(b)  
3 (  ) 4 ( ) 2 ( ) 1 (  )

(a)  
   
 (  ) M Bytes ( ) G Bytes ( ) K Bytes (  )

(b)  
  
 
 (  ) M Bytes ( ) G Bytes ( ) K Bytes (  )

(c) 
 
 (  )  G Hz ( )  M Hz ( )  K Hz (  )

(b)   
 (  )  G Hz ( )  M Hz ( )  K Hz (  )

Pin Diagram of 8051 Microcontroller

MS Electrical from LUMS 16


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Short Questions

IA_2013 / IIA-2013  PSEN 8051 /  PSEN 



     


IA-2016   GND Vcc 
IA-2016  
8051 
IA-2016    
 INT-1  8051 
IA-2016   I/O 8051 
2.1 Draw General Block Diagram of a Microcontroller

How Microcontroller Works

 
 
 
  

 disable   

 

  BitsSFRs  
          

    
    
  
   
 
 
  
0  
 
  
 

    
 

MS Electrical from LUMS 17


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968


 
     
     
  1    
  

repeat 

   
 
   

 
Essential Elements of a Microcontroller

  
  
( ROM )   ( RAM )  
( SFR )  ( EEPROM )  
 

   
 
( CPU )  
    
      
      
 
 

        

    
  


Short Questions


  
  
  
  
IA_2013/ IIA_2014 / IIA-2016   
 
2.2 Discuss Operation of each Block

( Random Access Memory )  


  
 immediate   
 
 RAM



 KBs
     
   

( ROM - Read Only Memory )  


 ROM 

 
 
 
 
 
ROM   
     
   Buit -in  
 

MS Electrical from LUMS 18


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

 
ROM
      
  
 
 ROM   Input/Output
  
 

Built- InROM
 
  
   
 
 
 Input/Output  
 64 K Bytes512 Bytes
    ROM
 

( Electrically Erasable Programable Read Only Memory ) 
 

 
 
 
 
 
  RAM   
 
   
    *

  slow   *

( Special Function Registers )  



       RAM 
  
  
    

( Program Counter )   
  
   
 
Engine    
 
  
  

    
   
  
 *



     
    1 

 
Jump subrutines
  
   
 *

 
 
( Central Processing Unit )   
  
   monitor        
  

  
  
   

    
      
( Instruction Decoder )    

    

  
   CPU  
 
    
    

 
( Arithmetic Logic Uint )    
 Subtraction  Addition              CPU   
 
 
 
   Division Multiplication

MS Electrical from LUMS 19


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

( Accumulator )   
  

  
 8
CPU 
 
  
  Operand    

     ALU 
  
     
      
      

  
  
  

( Inut/Output Ports )   


 
 
 
 
         useful 

  

      
   Input/Output
 

 
      
" 0 "

         
" 1 " 

( Oscillator )   
   
 
  
 
   

   
            
  
 

( Timers / Counter )     


  
             

   events 
 

  

MS Electrical from LUMS 20


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

  Timer/Counter
  T1 T0 8051
 
      
      
  
 
   


( Watch Dog Timer )
     
 
    RC
      




  
   
          
 
 
    
    
 
 CPU  RST
  
 
    
      
    
 CPU    
 
        
   


   
       

    
 Stuck   
    




   
  
    CPU        
 

    
  
 stuck       
  
 
 

( Power Supply Control )   
 
 



 
     
 
 Brown Out 
    
built-in   
         



  
     
 

   
  ( MCLR ) Master Clear Reset    Reset Pin 
 

    Brown Out 
 

( Serial Communication Unit ) 
  
 
     
    
   
 input/output

       
   
   

 
 

MS Electrical from LUMS 21


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968


   
 
      
    
  
  



( A/D Analog to Digital Converter )    
   " 0-1 "          
    

     
     
 





 A/D 
 


Short Questions

    RAM8051 



   RAM 
IA_2015 / IIA_2015 
   /  
 
IA_2013 / IA_2015
 

   
 
   ROM 
   ROM
  
IIA_2015  ROM 
IIA-2016 
  
 
  8051 
IA_2015 
   8051 
IA_2015 / IIA_2015    ROM
 ROM   /
  
 ROM
   
 Buit-In
   
 Limitation EEPROM 

IIA_2015 `   
  
8 Bit8051 

MS Electrical from LUMS 22


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

1A_2014     168051
 
IA_2013 / IIA-2016   

   /   
/   
/  
 
IA_2013 / 1A_2014/ IIA_2014 / IIA_2015 / IA-2016

IA-2016 
   


 8051 
   
  
PC 
IA-2016    TCONTMOD 
IA-2016    TMOD 
IA_2015    

    
Sub-Units   CPU 
    
IA_2013/ IIA_2014 / IIA-2016   ALU 
IA_2013 / IIA-2013 / IIA-2015   /
  /  
1A_2014  
   A
 
IIA-2013  B 
1A_2014   
 
8 
 
IA-2016 
  8  
 
 
1A_2014 / IIA_2015   PSW 
IA-2016   
   8051 
 
    
PSW 

    Bit-1 
PSW 

    ( OV Over Flow )   
PSW 
IA-2016   
 
 
    ( RS0, RS1 )  
PSW 

  Flag 0 
PSW 
   
  ( AC- Auxiliary Carry )  
PSW 
 
  ( CY- Carry Flag )  
PSW 
IIA_2014   DPTR 
   ( DPTR-Data Poiter Register )  
 
IIA-2013 / 1A_2014 / IIA_2015   
  /    /  
 

  
   
IA_2013   
IIA-2013  
 
IIA-2013   
IA-2016    
   
 
 

MS Electrical from LUMS 23


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

IA-2016  TXDRXD   P3


 
  ( P0, P1, P2, P3 Input/ Output Registers )    
 
 
IA_2013/ IIA_2014  
IA_2013   
1A_2014  8051 
IA-2016     
 
 8051 

 
1A_2014       8051 
  Input/Output 
Output Input8051 
       
IA-2016    8051
   
     
IA-2016    
8051 

  
 
8051 
 

    
  Brown Out 
1A_2014  UART 

     
IA-2016  
  
 
 A/D 
2.3 Discuss Buses in Microcontroller

( BUS )


 
 
   

 
  
  
   
( Data Bus ) 
   Data Bus   
         

       

  
  Bits
 *

   


  

 
 
  *

MS Electrical from LUMS 24


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

( Address Bus )

 
   
        
  Address Bus

 
        
  *

 16 Bit  
   Bits
 *


 
 
 *

( Controlling Bus )


    
   
              
  Controlling Bus
 
    

acknoledgements of Bus request 
 

  
 


Short Questions


  
   
IIA-2013 / IA-2016  
    /  
 
1A_2014   
    
    
IA_2013/ IIA_2014/ IA_2015   

MS Electrical from LUMS 25


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

ANSWERS OF THE SHORT QUESTIONS


   

 
 

     
  

  chip  


IIA_2015
   

  

 
    layout 
    
 
   

 

 

   

   


 

     

 







    
     
       
    

 

 

   
 
 RAM8051 
  128 
 RAM  8051

  
128         
   

128  
 0x7F0x00
 
 
  save      
  
 4 
Lowest 32  RAM

 
   
 

   recover 
 Stack  PUSH, POP  
IIA_2014   
  RAM 
   RAM
 
Dynamic RAM  Static RAM 
IA-2016     



 



   
      


1A_2014  

 24 
24 x 1024 = 24576 Bytes

MS Electrical from LUMS 26


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

IA-2016  

 20 
20 x 1024 = 24480 Bytes

    /     8051


1A_2014 
 

 
       SFR8051
  
 
Status SFR
 0xFF0x80
 



21  
 access SFR  I/O CPU 8051

 8051 
 

 CPU 
 
 
 

   
  

 
   
  
8bit     8 Bit   8051


 
 8051
A (accumulator), B, R0, R1, R2, R3, R4, R5, R6, R7, DPTR (data pointer) and PC (Program counter)

 8 Bit PC DPTR





Pin Diagram of 8051 Microcontroller

IA_2013 / IIA-2013   PSEN 8051 /  PSEN 


  
 
  

 ROM  

     

IA-2016 
 

 GND Vcc 

MS Electrical from LUMS 27


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

20GND 40Vcc
IA-2016  
8051 
  
 98051
IA-2016    
 INT-1  8051 
  
  INT-1 13 8051

IA-2016  I/O 8051 


  I/O Port_1 8051

2.1 Draw General Block Diagram of a Microcontroller

How Microcontroller Works

Essential Elements of a Microcontroller


  
  
  
  
  
   
( ROM )   ( RAM )  
( SFR )  ( EEPROM )  
 
   
 
  
   
     

MS Electrical from LUMS 28


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

 
( CPU )  
    
      

   
     

   


IA_2013/ IIA_2014 / IIA-2016   
 
 
 
( RAM, ROM, EPROM )   CPU 
( Timers/Counters, )  


2.2 Discuss Operation of each Block

  RAM8051 



    " 7F H "" 00 H " RAM   
128 K 8051
 

   RAM8051
  

Read / Write      

 
 " 1F H "" 00 H "32 ByteRAM
 
 

Read / Write   
Read /
  

 " 20 H " " 2F H "    16 Byte      RAM
Write
 
 
 

 80 Byte Read / Write  RAM

  
 
   " 7F H "" 30 H "

   
  
8051 *

 
    RAM 
  
 immediate   
  
 RAM

 
   

MS Electrical from LUMS 29


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968



 KBs
   
IA_2015 / IIA_2015 
   / 

 
 
  

  8051
IA_2013 / IA_2015     
 
 
 

  

 
 individual
 
  8051
 2FH20H
    
 16 bytes 8051
   ROM 
 ROM 

  
 
 
 
 
ROM   
   ROM
  
     
   Buit -in  
 

IIA_2015 ROM 

   user  
     
   

ROM
  MROM
IIA-2016 
  
 
  8051 

64 K Byte  
  4 K byte  
 8051
IA_2015 
   8051 
  
FFFFH   ROM 0FFFH

  ROM8051
IA_2015 / IIA_2015    ROM
ROM   /
  
  ROM
  
  ROM
  
   ROM

 ROM
    
 
ROM
      
  
 
  ROM  Input/Output  

 
 Buit-In
   

Built- In ROM 
 
  
   
 
 
 Input/Output  
 64 K Bytes512 Bytes
    ROM
 Limitation EEPROM 


 
  
   RAM  
 
 
   

MS Electrical from LUMS 30


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

    


  slow   Limitation

IIA_2015 `   
  

  
    
 
erase   
  

 
 
    erase    
   
   
8 Bit8051 
 
8 bit 8051
A (accumulator), B, RO, R1, R2, R3, R4, R5, R6, R7

 
    

1A_2014     168051
 
    168051

PC (Program counter)  DPTR (data pointer) 
IA_2013 / IIA-2016   

       RAM 
  
  
    

   /   
/   
/  
 
IA_2013 / 1A_2014/ IIA_2014 / IIA_2015 / IA-2016

  
   
 
Engine    
 
 1   
   
    
  
  
 
 

    
  

  
 Jump subrutines
  
   
 
IA-2016 
   


 8051 

" 0000 "  


 8051
   
  
PC 
  
  
   
     
   
   
     ROM  

CPU 


 

  
" FFFF H " " 0000 H "    16 Bit 8051
 

 


64 K
  
" 000C H "   " 0000 H "    
  
 


 CPU8051
  ROM 
  
 
  

MS Electrical from LUMS 31


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

   
    
  ROM     
 
 

IA-2016   TCONTMOD 

 " 8 bits "TCON TMOD8051
IA-2016    TMOD 

 Timer-0    
4     
    TMOD
Timer/counter    

  Timer-1    
4  


IA_2015    

 
 
  monitor   

    
Sub-Units  CPU 
 
 
  monitor      
  
 
  
  
  
    
      
    
  
   
   

  CPU 
  
     
    
IA_2013/ IIA_2014 / IIA-2016   ALU 
   CPU 
Division Multiplication Subtraction Addition

       




 

IA_2013 / IIA-2013 / IIA-2015   /
  /  
  

  
 8
CPU 
 
  
  Operand    

     ALU 
  
     
1A_2014  
   A
 
 
  A
 " E0 "
IIA-2013  B 
 
 B 
 spare  
  8 
 B A
    
 


1A_2014   
  8
 
255 
  8


MS Electrical from LUMS 32


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

( 1 1 1 1 1 1 1 1 ) 2= ( 255 ) 10
 
IA-2016  8 
  
 
 
 
8 FF 

 

1A_2014 / IIA_2015  PSW 
 ( Programe Status Word Register )  PSW
 
IA-2016   
   8051 
 
PSW 
  ( Programe Status Word Register )  
 
  


8      
    
  

 bits
 
   
PSW 
( Parity Bit ) 

 
  " 1's "   
  
 

 
 odd  "1's"    
 
0
 
 even  "1's"    
 
1 

    Bit-1 
PSW 
versions  
 unused  Bit-1 

    ( OV Over Flow )   
PSW 
( OV Over Flow ) 

     


     Arithmetical 
     
  
 

  
   
  
 
0


  
     
 
1 
IA-2016   
 
  
   


   


  over 
 
 
     ( RS0, RS1 )  
PSW 

( RS0, RS1 ) 

  4 BanksRAM
  

MS Electrical from LUMS 33


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

   
 
RS0-RS1 


  Flag 0 
PSW 
 
   
 Flag 0

  
  ( AC- Auxiliary Carry )  
PSW 

( AC- Auxiliary Carry ) 

 

 BCD 
  
 ( CY- Carry Flag )  
PSW 
( CY- Carry Flag ) 

 


 
IIA_2014  DPTR 
 " Data Poiter Register "    DPTR
   ( DPTR-Data Poiter Register )  
 
( DPTR-Data Poiter Register )  

8 Bits  
  

  

(    ) DPL   
  DPH 
     
 independent 
 16
  
 external
  
 
   immediate 
    

IIA-2013 / 1A_2014 / IIA_2015 


  
  /   
  /   
  
   
 
  

  
   
  
 


            



  
 
  1


MS Electrical from LUMS 34


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

 
  1
 7 RAM   
    7       
   
  
  
 

 
IA_2013   
  ALU    
      


IIA-2013  
 
 
    
  


 
  
  
   
CF=0  
 
CF=1
 
IIA-2013   
  
  

I/O 
 8 Bit RAM8051
 
   I/O  8051
 
Port_0 at 80H Port_1 at 90H Port_2 at A0H Port_3 at B0H

IA-2016      

  
 
TMOD, TCON, Accumulator, PSW

IA-2016  TXDRXD  P3


 
TXD 11RXD 10P3
   ( P0, P1, P2, P3 Input/ Output Registers )    
 
 
  

( P0, P1, P2, P3 Input/ Output Registers )  

 input/output 32  4 ports        
  
  
 peripherals 

  "     " 
   " 0 "  
 

  "   " 
   " 1 "  
  

   
    " 1 "  
    
 
IA_2013/ IIA_2014  
 

      
 SFR8051
 
IA_2013   

 

 asynchronous  
 asynchronous 
    
 
 RD WR 

  
1A_2014  8051 

MS Electrical from LUMS 35


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

  8051
IA-2016
 

   
 8051 
 

   
  

  
  8051
 
1A_2014       8051 

8051
8
 I/O   
 
  Input/Output 

 
 
         useful 
 
  

    
 Input/Output
Output Input 8051 
    

  
" 0 " 

        
 
" 1 " 

       



  
    
   

 
 
    
IA-2016    8051
   
   8051
12 MHz
     
  
             

   events 
 

  
      
      
  
 
   


IA-2016    
8051 
 Timer_1 Timer-0 
2 
8051

  
 
8051 

MS Electrical from LUMS 36


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

  Timer/Counter
  T1 T0 8051
 
 

    
 
    RC
      




  
   
          
 
 
    
    
 
 CPU  RST
  
 
    
      
    
 CPU    
 
        
   


   
       

    
 Stuck   
    




   
  
    CPU        
 

    
  
 stuck       
  
 
 

 Brown Out 




    
       
    
 
   

 
        
built-in        



  
     
1A_2014  UART 
 " Universal Asynchronous Receiver & Transmitter " UART


     
 
     
    
   
 input/output

       
   
   

 
 


   
 
      
    
  
  

IA-2016  
  

 


bit by bit 
 

MS Electrical from LUMS 37


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968
 

      

 

  
 A/D 
  " 0-1 " 
  


 
   
    
 




  A/D 
 

2.3 Discuss Buses in Microcontroller


  
   
 
 
   
   

 
     
IIA-2013 / IA-2016     / 
  
( Data Bus )

   Data Bus   


         

       

  
  Bits
 *

   


  

 
 
  *


( Address Bus )

   
        
  Address Bus

       
  *

 16 Bit  
   Bits
 *

  
   *

 
1A_2014       
    
  
  

 
    
IA_2013/ IIA_2014/ IA_2015   
    
   
               
  Controlling Bus
 
    

  acknoledgements of Bus request 

  
 



MS Electrical from LUMS 38


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Chapter 3

Instruction Set

  )
(

MS Electrical from LUMS 39


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

List of Operands and their Meaning

Discuss 8051 Instruction Set

 


       
    
  
   8051 
 
Branch Instructions  Arithmetic Instructions 
Logic Instructions  Data Transfer Instructions 
Bit-oriented Instructions 
Short Questions

IIA_2015 / IIA-2016   8051 /  


    

   8051 
IA-2016 
     
Data Transfer Instruction

 
   8051
 
  
 
 
  
 
 
 

MS Electrical from LUMS 40


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Short Questions

1A_2015   


1A_2015  MOVX 
IA_2013/ IIA_2014    
IIA-2013   Pop Push 
1A_2014  
" MOV R2, DPTR "   
IA-2016  invalidMOV R1DPTR 
Logic Instruction

   


    8051
Complement  Rotate  Exclusive OR  OR  AND 
 

  

MS Electrical from LUMS 41


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Short Questions

   / 


  /   
IIA-2013 / IA-2016 / IIA-2016

1A_2014
   ANL direct, A  

 
 
  /   
 syntex 
  /     
1A_2014 / 1A_2015 / IIA_2015

1A_2014   


 CPL A  
IIA-2013    
 

 
 
 
IIA-2016    
 
 
Arithmetic Instruction

 
     8051
         
  
    
 
  execute 
 

Short Questions

  Arithmetic Instructions 


1A_2015   ADD8051 
IIA-2013    INC
 
IIA-2013 
  DEC
  
1A_2014   
 

MS Electrical from LUMS 42


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Branch Instruction

 
     8051

 
    
  
  
 Subrutine 
 
 
  
 
    

Short Questions

IIA-2016    


IA-2016    LCALL ACALL 
 
IA-2016   DJNZ 
Bit- Oriented Instruction

  
 Bit    
    8051
  Bit-oriented Instructions

MS Electrical from LUMS 43


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Short Questions

   Bit-oriented Instructions 


  SWAP A
  

     8051 
IA-2016    8051 
IIA-2016 
 8051 
 80318051
  
IIA-2016  80528051
  
 
8052 
 
8031 

MS Electrical from LUMS 44


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

ANSWERS OF THE SHORT QUESTIONS


List of Operands and their Meaning

IIA_2015 / IIA-2016   8051 /  


    

       
    
  

 

    8051
 
 8051

Branch Instructions  Arithmetic Instructions 
Logic Instructions  Data Transfer Instructions 
Bit-oriented Instructions 
IA-2016 
     
SETB P2.3 ; Set pin 3 of P2 to high mean "1"

CLR P1.0 ; Clear pin 0 of P1 to zero "0"

Discuss 8051 Instruction Set

Data Transfer Instruction

1A_2015   


 
   8051
     
   
  
  
 
1A_2015   MOVX 
 MOVX  RAM 
    8051
IA_2013/ IIA_2014    
MOV A, Rn    
MOV Rn, A   
MOV A, #data   immediate
MOV Rn, #data  immediate
XCH A, Rn  
IIA-2013    Pop Push 
  POP   PUSH 
 
 
 
      
   8051
1  PUSH

  PUSH
PUSH A

        8051


1     POP

 POP 
  
POP A

MS Electrical from LUMS 45


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

1A_2014  
" MOV R2, DPTR "   
 
R2   
16  
DPTR     
 
  " MOV R2, DPTR "
8 
  16
8
IA-2016   invalidMOV R1 DPTR 
8  
 16   invalid   
8 
R1  
16  
DPTR
 
Logic Instruction

   / 


  /   
IIA-2013 / IA-2016 / IIA-2016

   


    8051
Exclusive OR  OR  AND 
Complement  Rotate 

   
1A_2014   ANL direct, A  


AND     
   8  ANL direct, A 
 
 
 
 syntex   /    
  /  
  
1A_2014 / 1A_2015 / IIA_2015

ANL direct, A

ORL direct, A

XRL direct, A

CLR A

1A_2014     CPL A  



  
 " 0's "  " 1's "  
  
  CPL A 

IIA-2013    


 

 
 
  06 lower    
  10 10

  Packed BCD 
  Packed BCD 
  
 
  

IIA-2016 
   
   

  "1's"  
"0"      
   8bit      CMA
 
"0"
   
 "1's"
Arithmetic Instruction

  Arithmetic Instructions 


 
     8051 
         
     
   

MS Electrical from LUMS 46


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

 
  execute 
 




1A_2015  ADD8051 


          8051
 
ADD

Show the status of CV, AC, P flag after the addition of 88 H and 93 H in following instruction

MOV A, # 88 H

ADD A, # 93 H

   A = 1B H, CV 1


  

IIA-2013 INC

   
 INC     ' 1 '       

    8051
  
INC A

   1  


 03H 02H 
 
IIA-2013     DEC
 
  DEC   ' 1 '       
     8051
  
DEC A

  1  


 02H 03H 
 
1A_2014   
 
ADD A, Rn

INC A

MS Electrical from LUMS 47


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Branch Instruction

IIA-2016    


 
     8051 

 
    
  
  
 Subrutine 
 
 
  
 
    
IA-2016     LCALLACALL
  
  
 2K byte 
   
 ACALL   
     LCALL  ACALL
 
 64Kbyte  LCALL
IA-2016   DJNZ 
Decrement and Jump if Not Zero

Bit- Oriented Instruction

  Bit-oriented Instructions 


  
 Bit    
    8051
  Bit-oriented Instructions
 SWAP A
  
 Higher Lower     
  



     8051 

IA-2016    8051 


  8051 
 
 
  
 
 8 Bit  8 Bit 

MS Electrical from LUMS 48


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

 

ROM  
  4K    
128 

 4    
 
 
 
  
    
 ROM  64 K 
IIA-2016 
 8051 
  
   MCS-51
8051 Interl
8031  8052 
 80318051
  
   ROM Less 8051
 8031
  
     ROM    ROM
      

 
 
   
64 K 

  ROM
8051
IIA-2016  80528051
  

 
8052 
 
  
RAM256 

3 
  standard  8051 
 ROM      
8 K  
 
 8052  
8051
 
 
8031 
 
  
RAM128 
2 
ROM  
64 K 
    ROM 

 2 
 I/O 


MS Electrical from LUMS 49


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Chapter 4

Memory Interface

(   )

MS Electrical from LUMS 50


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

8051 Memory Organization

  
   8051
 
  
  

( Program Memory ) 
 

8051    
       8051
  8051 
          
    4K 

60 K
  
   
   
 
64K 
 
 8051    

 

  
       Vcc     ( EA )     



    
     4K   
  


   


    
 
  
  ( EA )    
 


   
 
( Data Memory ) 

      


   8051



         
          
128   8051
 8051  64K    
       

64 K ( External ) + 128 Bytes ( Internal )       

MS Electrical from LUMS 51


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Memory Interface

     

 access    
 

 
 RD/WR
  RAM    256 Byte 8051
       RAM  
  
 8051 RAM  


   


14
  " 0 "  ( A13-A0 )  16K x 8
 OR  ( P2.7-P2.6 )    ( P2.5-P2.5 )   " 2 "  ( P0.7-P0.0 )
 " 2 "  
  
 


 RAM 
        LOWA15 A14
3FFFH0000H 


   0FFFH0000H
 
 

Short Questions

IIA_2015 
  
IA_2015   
IA_2013 
  
IIA_2015    
IA_2013    
 



  
     

 

MS Electrical from LUMS 52


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

ANSWERS OF THE SHORT QUESTIONS


8051 Memory Organization

IIA_2015 
  
  
   define
 
Memory Interface

IA_2015   



  

   
    

  
    
IA_2013 
  
 
  
  
   

IIA_2015    

 

 
     
 
     
  
  

IA_2013  
   
     
           
  

   
   CS ( Chip Select )



  
      
 
 ROM  4 K 8051 
    64 K 
 
   
4 K 
 
 
 ROM ROM8031 



 
    
 
 

MS Electrical from LUMS 53


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Chapter 5

Addressing Mode

 )
(  

MS Electrical from LUMS 54


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

5.1 Explain Different Addressing Modes

  
    
 
Direct Addressing Mode  Immediate Addressing Mode 
Register Indirect Addressing Mode  Register Direct Addressing Mode 
Index Addressing Mode 
Short Questions

IIA-2016 
    
IA_2013/ IIA_2014 
   
IA-2016   
  
 
Immediate Addressing Mode

 Immediate 
     

   
  
   
MOV A,#20h  
 


  20h  
  8

   
 Immediate


 Immediate


  
     

    
    

Short Questions

IIA-2013/ IA_2015  Immediate /   


  Immediate 
1A_2014   MOV A, #34H
   
 Immediate
   
Direct Addressing Mode

 Direct
  
  
  
 
MOV A,30h   
 

 30h
 
   
 Direct


Direct

 
 Immediate 

  
    Immediate   
 

     


MS Electrical from LUMS 55


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

   RAM 00h-7Fh


 
    SFR80h-FFh  

Short Questions

 
  
IIA-2016  MOV A, 30H
   
 
  
00h-7Fh
  80h-FFh
    
IA-2016  
  
Register Direct Addressing Mode

 Register Direct
      
   
MOV A, R4

 

 R4

   
Register Direct


  2Fh  
   2FhR4 
 

Short Questions

IA_2013 / IIA_2014 / IIA_2015  / 


  
Indirect Addressing Mode

   
   
      
       
 Indirect 
   
MOV A,@R0

MS Electrical from LUMS 56


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

   
 R0
   
  
Indirect  
 




  67h  
      40hR0 
 
  67h 
  
 SFR   Indirect
 RAM

Short Questions


   
IA_2013 
  
 
IA-2016 
     

 
Index Addressing Mode

 

  PC DPTR  
  
 
 Index
     
MOVC A, @A+DPTR

MOVC A, @A+PC


  

01FEh DPTR02h   

  
   
 Index


 
   0200h 

Short Questions

IIA-2013  Indexed
  

MS Electrical from LUMS 57


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

ANSWERS OF THE SHORT QUESTIONS


IIA-2016 
    
  
    
 
Direct Addressing Mode  Immediate Addressing Mode 
Register Indirect Addressing Mode  Register Direct Addressing Mode 
Index Addressing Mode 
IA_2013/ IIA_2014 
   

 
         
     
 

IA-2016   
  
 
 
  


5.1 Explain Different Addressing Modes

Immediate Addressing Mode

IIA-2013/ IA_2015  Immediate /  


  Immediate 
 Immediate 
     

   
  
   
MOV A,#20h  
 


  20h  
  8

   
 Immediate


1A_2014   MOV A, #34H
   
  MOV A, #34H
 
 " Immediate Addressing Mode "
 Immediate
   

  

       Immediate

      
   
Direct Addressing Mode

 
  
 Direct
  
  
  
  
MOV A,30h   
 

 30h
 
   
 Direct


IIA-2016  MOV A, 30H
   
Direct Addressing Mode

 
  
Direct

 
 Immediate 


   
    Immediate   
 

MS Electrical from LUMS 58


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

00h-7Fh
  80h-FFh
    

     

   RAM 00h-7Fh
 
    SFR80h-FFh  
IA-2016  
  

  Direct Addressing Mode
Register Direct Addressing Mode

IA_2013 / IIA_2014 / IIA_2015  / 


  

   
    
  
MOV A, R4

 

 R4

   



  2Fh  
   2FhR4 
 
Indirect Addressing Mode


   
 Indirect 
  

  
 
MOV A,@R0    
   
 R0
   
  
Indirect  
 




  67h  
      40hR0 
 
  67h 
  
IA_2013 
  
 
 Indirect 
  

  
 
MOV A,@R0    
MOV A,@R1

IA-2016 
     

 

 
dynamic static 
   




Index Addressing Mode

IIA-2013   Indexed 


 

  


  PC DPTR  
 
  
 Index
     
MOVC B, @A+DPTR

MOVC B, @A+PC


01FEh DPTR02h  

   
 Index


 
 B0200h 


MS Electrical from LUMS 59


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Chapter 6

Assembly Language


(   )

MS Electrical from LUMS 60


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Assembly Language
 
       
    
 

 

     
            


   

 
    
  
Syntax   Rules  Words 

 
    
  
 
 

( Comments )  

  ( Directives )  ( Orders )     ( Labels )   
 

    
   


 follow      
 

   syntax  


  255       

 
   

 
         


 
    
 
  " ; "  

       
   

 

 TAB Key 

( Numbers ) 

  
 
  

( Decimal Numbers ) 


    

 2 Bytes  16        
  


 65535  
 
  2 Bytes 

1234 D    " D "  
  
 
( Hexadecimal Numbers )   
 
 
  16   
   

 

   
 
65535FFFF       
  
   
  
  1234 h 
  " h "     
( Binary Numbers )  

  
   
   
       


MS Electrical from LUMS 61


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968



 " 11111111 11111111 " 
   
 " 1 " " 0 " 


10111011 b      " b " 

( Operators )  

 
        
    mathematical   
 

 
  
      
        
 
 Logical mathematical

( Symbols ) 
 
 
 
 

 
  assign  

 


    Stop 
         
 P0.3 

     assign   P0.3    
" pushbutton_STOP "
  
 
 ( " ? " and " _ " )( 0-9 ) ( A-Z , a-z )    


   case sensitive
  
 

    


       

 32     255 
  
 
   
   
 32 


   32      
 


 
      
     


MS Electrical from LUMS 62


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

" A or DPTR "


 
   
 assign
 

( Label ) 

 
 
 
   
    
 
   

 
 " : " 
 
  *



   

   
 *

( Directives )  

loader linker assembler
      
  

 pseudo-operations 
 directives     
 
 
   pseudo-opertions
 

    
EQU Directive

    EQU
   


99 " MAXIMUM " 
   
 

  
   
 
 

SET Directive


 
  EQU    
   SET
    
 
 
 SET

BIT Directive

  0-255  


    
  
   replace     BIT
 

MS Electrical from LUMS 63


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

CODE Directive

 
   
   
    replace     
 
  CODE


  0-65535 64K  

DATA Directive

  RAM  DATA


  replace
0-255
    
   assign 
  
 
 

IDATA Directive

    assign
 
     IDATA

XDATA Directive



 
 RAM  XDATA
     
  
65535

ORG Directive

  

   
    
  
  
 ORG




1024         100   
 
  



1000h

USING Directive

 
 
   USING
 
  


END Directive

MS Electrical from LUMS 64


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

  
 
   
   END
 

 

 
  
 
       
  END 



  
 

   
 5  5 
 

IF, ENDIF and ELSE Directives

 
   
 
   ELSE 
ENDIF IF  

 
 
 ENDIFELSE   

 IF 
ELSE  
  
  
 
    
IF

   
ELSE" 0 "  
   " 1 "  Model  
    
  

 
 
$ 

  compilation  
 

 execuitable 
 
 Listing   
compiled 
Short Questions

IIA-2013 
 
 
IIA_2014   
  
IIA_2014 / IA_2015     /     /   

IIA-2013       
 
IA_2013 / IA-2016     
    
  Draw  
   
  " Obj " " asm " 

   

  
 
  

MS Electrical from LUMS 65


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968


   
IIA-2013 / IIA-2016 
  
 
   
 / 
 
IIA-2013/ IIA_2014 / IA_2015 / IIA_2015  Operand / 
 
IA_2013/ IIA_2014/ IA_2015   /  
IA_2013 / IIA-2016  
 /     
IIA-2013   
  
IIA-2016 syntex 

IIA_2015  syntex 

   

  
  
 

 
  
 
   
2  
  
      

   
IIA_2015  
   BCD 
IA_2013/ IIA_2014   Packed BCD 
IIA-2013    Unvalid 
   
IIA-2016    

    

case sensitive  
 
   
   
     
 
   
    
   
IA_2013 / IIA-2013  
   / 
     
  
IIA-2015   

  pseudo-opertions
    
 EQU Directive 

   EQU 
  
  
   ORG 
IIA_2014     Set Directive / SET Directive 
 
 BIT Directive 
 
 CODE Directive 
  
  
Data 8051 

  IDATA Directive 

MS Electrical from LUMS 66


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

 XDATA Directive 


   USING Directive 
     END Directive 


  
  
  

 IF, ENDIF and ELSE Directives 
    
 
IA_2013/ IIA_2014   
  /     
 
IA_2013  
       

MS Electrical from LUMS 67


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

ANSWERS OF THE SHORT QUESTIONS


Assembly Language

IIA-2013 
 
 

  
   
 
 

  
 
 
    

  

 
  
     
  

  
  debug      
reliability  
 
  
 maintain   
IIA_2014   
 
 Data Structure  
    
     array, file, record , table and tree
   


  
IIA_2014 / IA_2015     /     /   
 
       
    
 

 

     
            

   


IIA-2013 
    
 
Careful Thinking of Problem 
Develop the Algorithm ( Sequence of steps to perform the required task ) 
Find the right instruction  Draw the flow chart 
Write Down the programe using the instructions 
Test and debugs the programe 
IA_2013 / IA-2016 
   
  
 
    
  
  
    
    
  Draw      

  
" Obj " " asm " 

MS Electrical from LUMS 68


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968


  DOS EDIT       " asm "
    
 
  

  
 " obj "     " asm " 
 
 
 
   " 1st "
    
 " obj " " asm "  
 

  
   
  

       


 
  
 syntex 
 
  
 
 

   

  
 
  

   
  
  


( Comments )    ( Directives )    ( Orders )     ( Labels )  

  
 
IIA-2013 / IIA-2016 
  
 
   /  
 

     
  
 

   
  
    
IIA-2013/ IIA_2014 / IA_2015 / IIA_2015  Operand /   
 
  
 
 
  
 
   

      
   
 

IA_2013/ IIA_2014/ IA_2015   /  
 
 

    
 
  
  
 
 
 
    *


  ()  *

  
   

      
  *

IA_2013 / IIA-2016    /     




 
     
  


  
     
 
IIA-2013   
 
 

 
  
 
  
  
   
   
    

  ( ; )  *

MS Electrical from LUMS 69


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

IIA-2016  syntex 


  

        
  

 follow       
   
 
  syntax

IIA_2015  syntex 


 255  
  
   

 
   

    
     


 
    
 
  " ; "  

       
   

 
 TAB Key  

  

  
    
 
( Hexadecimal Numbers )  
   ( Decimal Numbers )  
( Binary Numbers )  

  

     
  
 


1234 D    
 " D "  

 

 

   2 Bytes
16

  
 
    
2 
 65535  
 
  2 Bytes 
  
      
 
  16  
 
  


  

   


65535FFFF       
  
   
  
  1234 h 
  " h "     

   

  
              



 " 11111111 11111111 " 
   
 " 1 " " 0 " 


10111011 b      " b " 
IIA_2015  
   BCD 
Packed BCD Code

Unpacked BCD Code

MS Electrical from LUMS 70


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

IA_2013/ IIA_2014   Packed BCD 


  Packed BCD BCD  

 
74 = 0111 01000 
  "4" "7"
  Packed BCD     

 
IIA-2013     Unvalid 
Unvalid BCD Number for 13 Valid BCD Number for 13

1101 0001 0011

   



 
        
    mathematical   
 

 
  
      
        
 
 Logical mathematical

IIA-2016    


 
 
 

 
  assign  
 
 


    Stop 
         
 P0.3 


      assign   P0.3 
    
" pushbutton_STOP "

    
  
 
 ( " ? " and " _ " )( 0-9 ) ( A-Z , a-z )    


case sensitive  


  
 
  case sensitive

MS Electrical from LUMS 71


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

    


       

 32     255 
  
 
   
   
 32 


   32      
 

 
   
   

 
     
       

" A or DPTR "

    assign




  
 
  
 

 
 

     

 
 
 
   
    
 
   

 
 " : " 
 
  *

   


 
     
   
IA_2013 / IIA-2013  
   / 
     
  
 
     

  

loader linker assembler
       
 

    


IIA-2015   

loader linker assembler
      
  

 pseudo-operations 
 directives     
 
 
   pseudo-opertions
 

    

MS Electrical from LUMS 72


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

 pseudo-opertions
    
 
 
   pseudo-opertions
 

    
 EQU Directive 
    EQU
   


99 " MAXIMUM " 
   
 

  
    



   EQU  
 

   EQU 
 




 
 
 
 

 

 
  
        EQU
   
  ORG 
 
 
   
     
   
    ORG Directive
 



1024         100   
 
  



1000h

IIA_2014     Set Directive / SET Directive 



 
  EQU    
   SET
    
 
 
 SET

 
 BIT Directive 
  0-255  
    
  
   replace     BIT
 


  CODE Directive 
 
   
   
    replace     
 
  CODE


  0-65535 64K  

MS Electrical from LUMS 73


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

  
  
Data 8051 
DATA Directive ( DB )

  RAM  DATA


  replace
0-255
    *

   assign 


  
 
 *

 
  IDATA Directive 

    assign
  
   IDATA

  XDATA Directive 




 
 RAM  XDATA
     
  
65535

   USING Directive 


  
 
 
   USING
 

    END Directive 


  
 
   
   END
 

 

 
  
        
  END 
 
 

  
     

   
 5  5 
 


 IF, ENDIF and ELSE Directives 
 
   
 
   ELSE 
ENDIF IF  

 
 
 ENDIFELSE   
 IF
 
ELSE  

    
 
    

IF

MS Electrical from LUMS 74


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

   
ELSE" 0 "  
   " 1 "  Model  

  
    
 
  
 
$ 

  compilation  
 

 execuitable 

 Listing   
compiled 
 
IA_2013/ IIA_2014     /  
  
Fortran, Java, C, C++, Visual Basic, Python, COBOL
 
IA_2013  
       
    
 
          
 
       

  
 
   

   
     
 
       
 

    
    
 
   
 
  
  

MS Electrical from LUMS 75


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Chapter 7

Program Development

  

   
(    
 
)

MS Electrical from LUMS 76


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Programe Loops

   
 
    
  
    
    
 Loop  

 
   repete
 
  

  
 
Do/While Loop  Wlhile Loop  For Loop 
( For Loop )  


" For Loop "     
  
   
  
 
 
for ( [ expression1 ]; [ expression2 ]; [ expression3 ] )

for (i=0; i<5; i++)

expression


   

 evaluate expression  

   

    expression  
  expression 
 

  expression
( Wlhile Loop ) 

 
   

  
       while   

  
  
 while 

  


 FOR while
 

Do / While Loop

 
  
 
   
     Do/while

    For while 
 

MS Electrical from LUMS 77


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Short Questions

IA_2013/ IIA_2014 / IIA_2015 


 /  /   
  
IIA_2015 
 
  
IA_2015 / IIA_2015 / IIA-2016   / FOR /  

 While 
IIA_2015  Do / While 
Stack and Subroutine

 
   
  


  
  
 
 

    
   
 
 

 
   
 Subroutine

    
 



 
 
 
 


 
    
 
  
  reliable   
  

  
   
    
  
  
  


      

 Limitations  

 
 
 
  
    
     
  

 
   

   
      

 
      
LIFO

Nested Subroutine

 Nested 
     
 


MS Electrical from LUMS 78


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Short Questions

 /
  / 
   
 
IIA-2013 / 1A_2014 / 1A_2015 / IIA-2016 
 
  Nested Subroutine 
1A_2014 / IIA_2015 
  / 
 
 
 
 
   
1A_2015   /   accessed 8051 
IA_2015   CALL 
   StackCall 
IA_2013/ IIA_2014 / IIA_2015   
 /  
 " L CALL " 
" LJMP "" SJMP "
   
 A CALL L CALL
  
Function of Timer

 
      

  events
 

  
  Timer/Counter
  T1 T0 8051
 
      
      
  
 
   
 

Timer T0

8 Bits  Timer T0


    
TH0   TL0 
 
 High Low
16

 " 0 " 



   
 T0=0


  1000    232  TL0 3   TH0
   
1000 T0 
 
    

MS Electrical from LUMS 79


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

  
 
TH0 × 256 + TL0 = T



3 × 256 + 232 = 1000

   
    

 
 
 65535 
  16
  T0 

     
 
Short Questions

IA_2013 / IIA-2016   /  


  
IIA-2016   
 8051 
IIA-2013 

 
       Timer/Counter 
IIA_2014   T0/    Timer T0
  
Describe Input Capture

           deal embadded



 

    
   

      
      
    embadded 
 
  
 

        
   
   
    
     
   
 
       



 event   

   
Short Questions

IA_2013 / IIA-2013/ IIA_2014   Capture / capture 


 
  

1A_2014 / IIA_2015 / IIA-2016 
  /  
   /  Capture  
 
 


   
 

 
     
IIA_2015 
  
Describe Output Compare/Capture

  
  
 
 
 
      
 
 
embadded

 

 event    
   
    
 
   

    
  
  
 

Toggle    
   
 
 
 
Short Questions

    


 
 
   
  
 

MS Electrical from LUMS 80


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Programe Development
 
 

  
Dvelopment 
   
  
 
 
Debugger / Simulator  Compiler  Assembler   Editor 




( Editor ) 

 
  
   
 

 
  
 
  
 

 
 
 RAM  ASCII  
 
   Alert     

 

  
 

  
 
 
 

 

  Source   Save 
   

( Assembler ) 

    

     

 
  
 
    

 
   
    
   
  
( . hex ) 
 



 Absolute
       
sequence 
( Compiler ) 
 
 " C "      
  
 

  
 

 
  
     

Debugging   Flexibility    
 



( Debugger / Simulator ) 

 
   
 
  
    
  

 
 
 
 
  
   
 
PC 


  
  

  
      
       
 

 
           
     

 
  
   
      
   




   
 
  
 
 
 
 

MS Electrical from LUMS 81


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Short Questions

IIA_2015 / IIA-2016    
 
   
/ 
  
  

   

     

   
  
   

       
IIA-2016   
1A_2014/ IIA_2014 / IIA-2016    /   /
  
 
   

MS Electrical from LUMS 82


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

ANSWERS OF THE SHORT QUESTIONS


Programe Loops

IA_2013/ IIA_2014 / IIA_2015 


 /  /   
  
   
 
    
  
    
    
   
 
 
   repete 
 
    

 Loop

IIA_2015 
 
  
  
 
Do/While Loop  Wlhile Loop  For Loop 
IA_2015 / IIA_2015 / IIA-2016   / FOR /  

" For Loop "     
  
   
  
 
 
for ( [ expression1 ]; [ expression2 ]; [ expression3 ] )

for (i=0; i<5; i++)

expression


   

 evaluate expression  

   

    expression  
  expression 
 

  expression
 
 While 
 
   

  
       while   

  
 while 
  
 FOR while
 

IIA_2015   Do / While 


 
  
 
   
     Do/while

    For while 
 

Stack and Subroutine

 /
  / 
   
 

MS Electrical from LUMS 83


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

IIA-2013 / 1A_2014 / 1A_2015 / IIA-2016 


 

 
   
  



  
   
 

    
   
 
 

 
   
 Subroutine

    
 

 
  " Call "
   Nested Subroutine 
 Nested 
     
 


1A_2014 / IIA_2015 


  / 
 
 
 
 




 
 
 
 


 
    
 
  
  reliable   
  

  
   
    
  
  
  



      

 Limitations  

 
 
   
 
  
    
     
  
 
 
   

   
      

 
      
LIFO
1A_2015   /   accessed 8051 

 
FILO  
  RAM 
  
  

MS Electrical from LUMS 84


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

 
    
    
 
            
 
   CPU  
 RAM 07  SP 
 8051    SP
 FF 00   8 Bit
 08
 POP
  PUSH
  
 
Pushing The date on the Stack 
 PUSH  
        
 
     8051
  SP 
 

 
Poping The date from the Stack 
 SP  
        
  POP 8051


 

 
2F20   1F088051
   
  SP 
24 Bytes 
 
“ MOV SP, # X X ”.

IA_2015  CALL 


  CALL  
   
    8051
   Stack Call 
   
    
     
  
Call

    
    
  
 
   
    
   
  
    
   call      
 

  
 
 
IA_2013/ IIA_2014 / IIA_2015  
 / 
 PUSH 
    
   8 bit 
 
 
 
 
 1   

 
  " L CALL " 
L CALL

  3 Byte  
 

 
 
     Subroutines  
  
  RAM  
 64 K  8051  " L CALL "   
  
  
" LJMP " " SJMP "
  
     SJMP
2  


    
   

 


MS Electrical from LUMS 85


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

 
 
 
 
   
 
 
   
3 LJMP
 
 A CALL L CALL
   
L CALL

  3 Byte  
 

 
 
     Subroutines  
  
  RAM  
 64 K  8051  " L CALL "    
  
  
  Absolute A CALL


11   
2   
 2 K Bytes 

      
  
2 
  

  64 K
   L CALL  
  

 
  
2 K   A CALL

 
 ROM 
 A CALL L CALL
Function of Timer

IA_2013 / IIA-2016   /  


  
 
8051      
   
    
 

 
   event
     events
 
 baud
   

 
    
 
IIA-2016   
 8051 
  Timer/Counter
  T1 T0 8051
 
IIA-2013  
 
 
  TH0  TL0  
Timer_0 8051



2550  
 TH0TL0
      Timer/Counter 
    
      
   
 
   
 

IIA_2014    T0/    Timer T0


  

MS Electrical from LUMS 86


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

8 Bits  Timer T0


    
TH0   TL0 
 
 High Low
16

 " 0 " 



   
 T0=0


  1000    232  TL0 3   TH0
   
1000 T0 
 
    

  
 
TH0 × 256 + TL0 = T



3 × 256 + 232 = 1000

   
    

 
 
 65535 
  16
  T0 

     
 
IA_2013 / IIA-2013/ IIA_2014 Capture /capture 

    
    deal
  embadded

 

 
  
  
  
 
 
         
 
 embadded  
 

  
Describe Input Capture
 
  



1A_2014 / IIA_2015 / IIA-2016  / 
   /   Capture   

    
      deal embadded
 


   
 

 
  
   
  


 

 
   
 


    
 
      
 

 
     
 


   
  
       
  


 event          
IIA_2015   
 
 
 
  
edge 
 

   

edge 

 
      
  

MS Electrical from LUMS 87


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968



Describe Output Compare/Capture

   
 
  
  
 
 
 
      
 
 
embadded

 
   
    

 

 event    
   
    
 
   

    
  
  
 

Toggle    
   
 
 
 
Programe Development

IIA_2015 / IIA-2016   
  
   
/ 
  
  
 

 

  
Dvelopment 
         
Debugger / Simulator  Compiler  Assembler   Editor 



    

 
  
   
  
 
  

     
 
  
 

 
 
 RAM  ASCII  
 
   Alert    

 

  
 

 
   
 

 

    
 

  Source   Save  
  
   
  
 
     
 
  
 
    
       
 
   
      

( . hex ) 
 



 Absolute
       
sequence 
IIA-2016   
 
 " C "      
  
 

  
 


MS Electrical from LUMS 88


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968
 
  
     

Debugging   Flexibility    

  

1A_2014/ IIA_2014 / IIA-2016    /   /
  
 
   
 
  
    
  

 
   
 
 
 
 
  
   
 
PC 


  
  

  
      
       
 
 
 
          
     

 
  
   
      
   



   
 
  
 
 
 
 

MS Electrical from LUMS 89


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Chapter 8

Interrupt and Interupt

Application

 
(    )

MS Electrical from LUMS 90


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Interrupt

 
ISR  
   
   
event  

     
  
 
 
 
 
 
 

 

   asynchronous events     

 ISR   deal 
 
 routine    
   driven 
  



 external internal 

Short Questions

IIA-2013 / IIA-2016  / 


  
  
   
 
 
   

 
MCQ's


   
 
 event 
 (  ) Debugging ( )  ( )
  (  )

events ................  
  
 (  )  B  A ( )   ( )  (  )

Types of Interrupt


    
   


    

 
   
   
  
 
 
( Maskable Interrupt ) 
 
 
 
   
     
  
 
  

   
 execute 
         
 
( Non Maskable Interrupt ) 
    


    
 execute    

  

     
  

 

 
   


    
  
 

MS Electrical from LUMS 91


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

( Hardware Interrupt ) 



    

    
 

  INT 
 
( Software Interrupt ) 
 
 
  

 
( Error Interrupt )  
 
    

 
 
 execute  


 
 
  


Short Questions

   


IIA_2014  
     

        


  
IIA_2014   /  
   
IA_2015 
    8051 
 
   

   
8051 Microcontroller Interrupts

 events
     
 
   58051
EA  disable enable  
  IE
 
 8051

  
  
     disable

 
   IT1IT0
 " 1 " TCON  INT1INT0
  
  

   TCON 
 " 0 " IT1 IT0     
 

  LOW  
 
    
 
 ( IE )  8051

   8
   
     
 8051

MS Electrical from LUMS 92


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968


( Interrupt Priorities )  

 8051  
 
 
 
 
 
   
 

  
   
  
 
  Reset 
 

   
 
    disable 
   Interrupt Priority 1 
 
 Interrupt Priority 1
 
  Interrupt Priority 0 

( Interrupt Priority Register )   


 
 specify 
 8 
8051

   
  
 
 


  
  
 
  
stop  
   
  
   
  
   
 
    
 
   
      
 
 

 
 
 
   
  
 
 
INT0 
 Timer 0
 
 
INT1 
 Timer 1
 

 
( Interrupt Handling ) 
 
  
    
   
  
   

      

PUSH  

 
 
   
  
 
5 

 


MS Electrical from LUMS 93


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

 

 
  
   
 
 
  
       
 

 
 

Short Questions

8051 / 
  8051 / 

 8051 
1A_2014 / IIA_2014 / IIA-2016

IA-2016  8051  
  
 
  disable enable

 8051 
IIA_2014   IE 
1A_2015   IE 
    
  
 ( IE ) 
 8051 
1A_2014 / IIA_2015  
 / 
 
 

  

8051
 
  

 
   

 
IIA_2015 / IA-2016  / 
   
 ( Interrupt Handling ) 
   
 
IA-2016    8051  priority 
priority8051
 

MS Electrical from LUMS 94


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

ANSWERS OF THE SHORT QUESTIONS


Interrupt

IIA-2013 / IIA-2016  / 


  

  
 
  
event  
  

    
   
 
  
   
 
  
   ISR  
   
    

    
 
 

 
 


 
   

 

   asynchronous events     

 
   driven 
  


 

  ISR  deal 

 routine 
 external internal 

Types of Interrupt


   
 
  

 
   
   
  
 
IIA_2014      
 
 
   
     
  
 
  

   
 execute 
   
     
 
       


    
 execute    

  

     
  

 

 

  
   


    
  
 
IIA_2014   /  
   
          
    
 

  INTR 
IA_2015 
    8051 
INT1  INT0 
 
   
INT  
    
  

MS Electrical from LUMS 95


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968


   
   
 
 
   execute 
   

     
 
8051 Microcontroller Interrupts

 events
     
   58051
 
8051 / 
  8051 / 

 8051 
1A_2014 / IIA_2014 / IIA-2016

 events
    
   58051
 
IA-2016  8051  
  
 6   
   58051
  disable enable 
 8051 
  disable enable   IE
 
 8051

  
  
     disable EA

IIA_2014    IE 


  " Interrupt Enable " IE
 
1A_2015   IE 
 
 disable enable

  Interrupt Enable IE
    
   
 ( IE )  8051 

   8
   
     
 8051

MS Electrical from LUMS 96


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

1A_2014 / IIA_2015  


 / 
 
 
  
 
 
 
 
 

  

8051
 
   
 8051

    
          
   
 Reset 
 

   
 
    disable 
   Interrupt Priority 1 
 
 Interrupt Priority 1
 
  Interrupt Priority 0 
  

 
 
  
 
 specify 
  8 
8051
 
 


  
   

 
   
  

   stop
  
  
   
 
   
  
   
 
    
 
   
       
  
  

 
 
   
  
    
 
INT1   Timer 0
   
INT0 

   Timer 1
 
IIA_2015 / IA-2016  / 
   
  
 
 
 
( Interrupt Handling ) 
  
 
   
    

   

      

PUSH  

 
 
   
  
 
5 

 


 

  
             
  
 
  
       
 

 
 

MS Electrical from LUMS 97


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

IA-2016  
   8051  priority 
priority8051
 
 priority  8051  
     
 priority    
priority 8051 

 

MS Electrical from LUMS 98


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Chapter 9

Peripheral Support Chip

 
(   )

MS Electrical from LUMS 99


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

 
  
  




   

  
 
   
  
 
    
 
    Useful 



      

    
 

 
 
 
 
 
   
   
  
( Power Supply ) 



5 V 
  5 V     

  

  
 

  

 DC    

       

   

  
   
    IC 
 
  

  LM 7805 DC   

5V  


   
       DC

 
   

 
( Reset Signal ) 
 
 
 


   
  
   
   
RS   

   
Stuck  
 RS


 
 
 
 
    
RS 
  
 


  
( Clock Signal ) 

  
       

  
  Built-In

    
 Determine  

    
   
  

MS Electrical from LUMS 100


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968


( Switches & Buttons ) 



  
 
   
 
 
   
 


 

  
    
  





  sense  
   

( Relay )  

  
 
  

  
 
 


    


         
 


 
 
 
 


 
   
  
 
 
    
  
 


 
  
   
  Darlington Pair 




( LED Display )   



   
  
 LED  LEDs 
    


MS Electrical from LUMS 101


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

  
  
   

   
 


 
  

     
LED            

 
  

 
   
  LED       
 LED



    
 
  
 LED          
 

  
   
   LED   
    LED

( LCD - Liquid Crystal Display ) 


  
     
  

 
4 Bit LCD  8 Bit LCD 
 Initialization 


  LCD

MS Electrical from LUMS 102


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

  LCD 


    D7D0 8 Bit LCD

 
 4 Bit LCD
  
( Optocoupler ) 



  
  
 
  
  
  
 
 


LED  
       
LED
   
 
 
  
  
  
 
 

  GPIO input/output
 

 
Short Questions

    


   

   
IA_2013 / IIA-2013 / IIA-2015      /       

IIA-2013     

IA-2015   
    
  useful  


 
   
 
   
  

   

         
 
 
 
   
 
    
 
IIA-2015  LED 
IIA-2013   LED 
   
IIA-2016 
 
 GPIO  
Peripheral Support Chips

  GPIO  input/output
 
  
 
   
   
 GPIO           
 
 GPIO


MS Electrical from LUMS 103


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

    


 
 


   
 

 
  
  LED 
  
  

A/D ( Analog to Digital Converter ) 
  

   
 embaded
    
    
   
     

  
      A/D   
   
 



D/A ( Digital to Analog Converter ) 
 
   

      
        
 

 

  
 
   D/A  
   
     

PIT ( Programable Interval Timer ) 
  

  

    
    
  embadded    

PIT

     

  
      PIT



 
    

   
     


Heater   
Air Conditioner  
     

PWM ( Pulse Width Modulation )   

  CPU


  
   

     
    

 
   

     
 

 



UART ( Universal Asynchronous Receiver / Transmitter )   


     
      UART

   
    
   
(Inter Integrated Circuit) IIC 
SPI ( Serial Peripheral Interface )  
 

MS Electrical from LUMS 104


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Short Questions

  
  
IA_2013  
  
  
  
IIA_2015  ADC 
IIA-2016     

   
IIA_2015  PWM 
  
    
IIA_2015   
IA_2015    
 
 
 
    
 
 
IIA_2015  USART 
IIA-2016  UART 

IA-2016  
  

MS Electrical from LUMS 105


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

ANSWERS OF THE SHORT QUESTIONS


    
   
    
    
       
 
 
   
   
IA_2013 / IIA-2013 / IIA-2015      /    
  
 
   
     
    
( Key board, Mouse, Webcam, Mic, Light pen etc. )      
( LCD, Monitor, Speaker, Printer, Projector, Plotter )     

   

IIA-2013   
  

    
   

Key Board, Mouse, Printer, Monitor, Speaker, Joy Stic etc......

IA-2015 
  
  
  
Key Board, Mouse, Printer, Monitor, Speaker, Joy Stic etc......

  useful   


 
  
  
    
  
   Useful 


       
 
   
    
   



            
    

  
 
      
   
 


 

  
    
  





  sense  
   

  
  
 
  
  
 
 



   


          
 



  
 


   
  
 LED  LEDs 
    


MS Electrical from LUMS 106


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968


   
  
  

  
  
   

      
 
   
   
 
     
LED             

 
  

 
   
  LED       
 LED


   
   
 
  
 LED         

 

  
    LED   
    LED
IIA-2015  LED 

   
 LED     
 
  PN
IIA-2013    LED 
     
 per lumen 


 



   
     
  
 
   
 
  


     
 
   

  
     
  
 
4 Bit LCD  8 Bit LCD 
  Initialization  

  LCD

  LCD 

      D7D0 8 Bit LCD
 *

 4 Bit LCD
  *

IIA-2016   




  
  

 
       
  
 


 GPIO  
  GPIO input/output
 

 

MS Electrical from LUMS 107


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968
 
     
 GPIO
      
    
  GPIO


    
 
 


   
 

 
  
  LED 
 
  
Peripheral Support Chips

  
  
  

   
 embaded
    
    
   
     

  
      A/D   
   
 


IA_2013  
  
 
 
    

   
  
  
 
    

      
        
 

 

  
 

  D/A  
   
   

   

IIA_2015   ADC 


 
 
  ADC     
 ADC 

IIA-2016     

   
 PIT
 
  
embadded


     

  
      PIT



 
    
   
     


Heater   
Air Conditioner  
 
    
IIA_2015  PWM 
 " Pulse Width Modulation"  PWM
 
       
    CPU 
    
  
    
   
    



MS Electrical from LUMS 108


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968


     
 

IIA_2015   

    
    
    
     
 


  
  

IA_2015 
  
  
    rules
 
 
 
    
 
 


   
  
    UART
   
   
  
SPI ( Serial Peripheral Interface )   IIC 
 
IIA_2015  USART 

" Universal Synchronous/Asynchronous Receiver/Transmitter " 


USART
  
RS_232C
IIA-2016  UART 
 " Universal Asynchronous Receiver/Transmitter " UART

IA-2016  
  
  
  
   
 

MS Electrical from LUMS 109


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Chapter 10

Digital Interfacing

(  )

MS Electrical from LUMS 110


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

What is Meant by Interfacing

       


 
  

  
 
    
 
 
  *




         

    
 


   
Power Consumption   weight     



    Avalibility  Relialability 

 
 
  
  
 
    
 

  

   

 
   
      
  
   
( Digital Interface )  
   
      

 On/Off 
 
 
( Synchronous ) 
Ethernet  RS 232 / RS 485  1 Wire 
( Asynchronous ) 
4-Wire ( SPI, Microwire )   2- Wire ( 12C ) 
 On/Off 


 
    I/O

  
 
    


  
   
 

MS Electrical from LUMS 111


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

  
 
 
   On/Off 
 



 LDE  

  
 

  On/Off 

   




 
  

     
   
 

 
32 Bit  16 Bit  8 Bit  4 Bit 
    LCD


  
  

MS Electrical from LUMS 112


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Short Questions

IIA_2014   /    


IIA-2013 
  
 
 
 
  
   
IIA-2016  

  
  
  On/Off 

      
   
IA_2013 / IIA-2013 / IA-2016  LCD /  LCD
   

    

  
  
 
   
  2- Wire ( 12C ) 
2- Wire ( 12C )
  
Serial Inter Face

 
  
 
( Asynchronour ) 
IIC ( Inter Integrated Circuit Bus ) 



2
 
 

   
 
    SCL    SDA 

     
     
    
 *

 
   

 

       
  *

  


   *

MS Electrical from LUMS 113


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

SPI ( Serial Peripheral Interface ) 



4
 
 

   
CS ( Chip Select )   CLOCK  DATA OUT  DATA IN 
 
  
Slave Master     
  

  
     
 
 SPI
 
 Full Duplex 
  
 

( Synchronour ) 
1 Wire 
 
       Dallas 
 
 

  
 
  
  pair      carry
    
 
   
 
  
 

RS 232 

RS 485 

MS Electrical from LUMS 114


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Ethernet 

Short Questions

  SPI ( Serial Peripheral Interface ) 


IIA_2014    
SPI ( Serial Peripheral Interface )
  

  
  
   1 Wire 
 1 Wire
   
IIA-2016 RS-232
  
 RS 485
   

   Ethernet
 
IA_2015  CSMA/CD 

MS Electrical from LUMS 115


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

ANSWERS OF THE SHORT QUESTIONS


What is Meant by Interfacing

IIA_2014   /    



   
   
  

 
   
    
 
     
IIA-2013    
 
   
   
 
   


    
 
 
 

 
weight     
Avalibility  Relialability  Power Consumption 


   
 
  
   
      
   
   
IIA-2016  
 
     


  
  
  
 
     On/Off 
  On/Off 


 
     
I/O  
 
    

      
 


  
   
   On/Off 
 


   
 LDE  
 

 On/Off 

      
 
    

MS Electrical from LUMS 116


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

   


  

       
  
 
32 Bit  16 Bit  8 Bit  4 Bit 
IA_2013 / IIA-2013 / IA-2016 LCD /  LCD
   
 
     
       

    
  
  


  
  
 
  
  
 
( Synchronour )  ( Asynchronour ) 
   
  
  
 
4-Wire ( SPI, Microwire )  2- Wire ( 12C ) 
  2- Wire ( 12C ) 

 2
 
 

   
 
    SCL    SDA 

   


     
   

 
   



        
 
 2- Wire ( 12C )
  
  
 

MS Electrical from LUMS 117


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Serial Inter Face

  SPI ( Serial Peripheral Interface ) 


 
4  
 


   
CS ( Chip Select )   CLOCK  
DATA OUT DATA IN 
 
  
Slave Master     
  

   
 
   
 SPI
 
 Full Duplex 
IIA_2014    

 
  
Slave Master      
 

    


     
 SPI
 
 Full Duplex 
SPI ( Serial Peripheral Interface )
   
  
 


  
  
  
  
 
Ethernet  RS 232 / RS 485  1 Wire 
  1 Wire 
   
  
   Dallas  
 
 
  

  

  
 pair     carry
 



 1 Wire
  

IIA-2016  RS-232


  

MS Electrical from LUMS 118


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

RS 485
   


   Ethernet
 

IA_2015
   CSMA/CD 
  
 
 
    carrier sense multiple access/ collision dection  CSMA/CD
 
           
    
  


MS Electrical from LUMS 119


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Chapter 11

Analog Interfacing and

Industrial Control

  )
( 

MS Electrical from LUMS 120


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968


 
 Real World 
  
   
 


   
 
 
    A/D
 
  
  Useful 

     
Data Acquistion and Control 
 
 
 ADC
 ADC  8051
  
 





 

  A/D 
  
 
 
  


  


 

   
 
  
       




   

    
     
 D/A    
 
    

  




   
   

Short Questions

 
IIA-2013   
  

MS Electrical from LUMS 121


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

    


IIA_2014   
IA_2015 / IIA-2016  /  
 
    
 
IIA-2013     

 
    
 
IIA-2013/ IA-2015  
 /
  



 
     

MS Electrical from LUMS 122


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

ANSWERS OF THE SHORT QUESTIONS



 
IIA-2013   
  


 



       


 


 
 piezo    
 

 
 
    

       Real World    
   
   
 


   
IIA_2014   

       Real World    
    
    
 
 

   

IA_2015 / IIA-2016  /  
  
    
   


  

 
     
 

      
    
 A/D     
 


    
  Useful 

 ADC
 ADC  8051





IIA-2013  
  
 
     

    
      
 
   

   
   


    
 
         
   
 
 

      
   
       
  D/A     
 
    

  
IIA-2013/ IA-2015    /  



 

         
 




       

MS Electrical from LUMS 123


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968



   
   

MS Electrical from LUMS 124


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

Chapter 12

Microcontroller System

Application

(   )

MS Electrical from LUMS 125


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968


( Angular Speed Measurement )   


 
   
  
   

  RPM  
 



 
 
    



  
   
  


    


 
  Toothed  
  
   
    
 
  
   
 
  
      
       


 
  square   
 
  
 120 Hz   square360 r.p.m  20   
 
 
      T0   
     
 
 
 
    " 1 "          " 1 "       



 

  
  
        " 1 "
        T0 

 

        


 
 
       
  BCD   PORT 1   

  
 
  


( DC Motor Speed Control )    PWM



  
 
  
   

             
 


 
     
  
       
 
   PWM  


                
   
 
 
   
  MOSFET    
   

MS Electrical from LUMS 126


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

 
   PWM      
     



       
 


 
  
  
         
      MOSFET 

   
    
   
    MOSFET

 
      
    
 
    
 MOSFET 
 
        
 
      MOSFET  
 

 
AC TRIAC
    


           AC



 AC  AC
 Load
  

 
     
   


  AC




      
     LED          
     




  
    
     LED      


MS Electrical from LUMS 127


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

 
   
 LED

   AC
 
   
  
LED
   
 

  
    
   TRIAC  
  AC
 



       
  TRIAC
Short Questions

IA_2013 / IIA-2013   LM35 


1A_2014  
 

  
1A_2014 
    
IIA_2015   

MS Electrical from LUMS 128


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

ANSWERS OF THE SHORT QUESTIONS


IA_2013 / IIA-2013   LM35 

 
   
 precision     

 
   
 +/-
  
    Low

 
 easy 
1A_2014  
 

  
 

     


      

 

1A_2014 
    
    
IIA_2015   
 
 
      


MS Electrical from LUMS 129


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

ELTR_343
( Third year )

MICROCONTROLLER

PROGRAMMING & APPLICATIONS

PART_A

Mcq's form 5 year

Past Papers

MS Electrical from LUMS 130


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

DAE/IA_2013

ELTR_363 MICROCONTROLLER PROGRAMMING AND APPLICATION

Time: 30 Minutes PART_A Marks:20

Q.1 Encircle the correct answer.     


 
1. The divices which are used between computer system and user are called:

   



 (d)

(a) Mass storage device (b) Modem (c) Printer (d) Input & Output devices

2. RAM is a:   (a)

(a) Read/write memory (b) Read only memory

(c) Non volatile memory (d) Only write memory

3. The four layer device is called____:   


  8051 (a)

(a) 240 bit (b) 210 bit (c) 230 bit (d) 260 bit

4. In 8051 microcontroller bus control signals are:  8051 (b)

(a) 2 (b) 3 (c) 1 (d) 4

5. Address range of special function register bank are:   bank


 (d)

(a) 00H-77H (b) 00H-FFH (c) 80H-87H (d) 80H-FFH

6. In 8051 microcontroller internal memory space is: 8051


 (b)

(a) 210 bytes (b) 256 bytes (c) 32 bytes (d) 64 bytes

7. Long addressing is used with the instruction: 


  (a)

(a) LCALL (b) LOOP (c) PUSH (d) POP

8. In 8051 logical instructions performs: 8051



    (b)

(a) Arithmatic operation (b) Boolean operations

(c) Single ended operation (d) Double ended operation



9. An Assembly language program is often called: 
   
  (b)

(a) Machine code (b) Source code (c) Pseudo code (d) Syntax code

10. The ASCII code for "A" is:  ASCII  A (a)

(a) 41H (b) 66D (c) 0100 (d) 0011

11. An RS-232 interface is:  


 RS-232 (b)

(a) Parallel interface (b) Serial interface (c) Printer interface (d) Modem interface

12. In 8051 address bus consists of: 8051


  (c)

(a) 8 bit (b) 4 bit (c) 16 bit (d) 2 bit

13. Structured programming is a technique of: 


  
 (d)

(a) Program code (b) Program execution (c) Program reading (d) Program compiling

14. The 4-bit binary number 0111 represent:  0111


  4
 (b)

(a) 15 (b) 7 (c) 4 (d) -7

15. In micro controller data bus is:    (b)

MS Electrical from LUMS 131


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

(a) Uni-directional (b) Bi-directional (c) Any direction (d) Non direction

16. In 8051 micro controller pins used for crystal oscillator:    
 (d)

(a) 11-12 (b) 18-19 (c) 30-31 (d) 39-40

17. Logical operator is: 


 (b)

(a) MOV (b) XOR (c) JMP (d) INC

18. Absolute addressing used with the instruction:  Absolute


 (a)

(a) ACALL (b) MOV (c) ADD (d) DEC



19. Assembly language program translated to machine code by:  
 
  (b)

(a) Assembler (b) Compiler (c) Linker (d) Timer

20. Microcontroller device is a:  (b)

(a) General purpose (b) Specific purpose (c) Multi purpose (d) No purpose
DAE/IIA_2013

ELTR_363 MICROCONTROLLER PROGRAMMING AND APPLICATION

Time: 30 Minutes PART_A Marks:20

Q.1 Encircle the correct answer.     


 
1. Pictorial representation of program is called:   
   
  ( b )
(a) Program code (b) Flow chart (c) Program graphic (d) Machine code

2. Series of instruction to perform task is called:  


   
 (c)

(a) Flow chart (b) Data (c) Program (d) Operation code

3. 16 bit Address bus can access location:   


  
16 (b)

(a) 65,580 (b) 65,536 (c) 66,072 (d) 64,540

4. In 8051 micro controller on chip crystal oscillator frequency is:

 
   

  
 8051
 (b)

(a) 20 MHz (b) 12 MHz (c) 10 MHz (d) 24 MHz

5. In 8051 microcontroller internal memory space range is:  8051 (a)

(a) 00H-80H (b) 00H-FFH (c) 00H-7FH (d) 00H-EFH

6. In 8051 microcontroller special function registers are:   8051 (a)

(a) 21 (b) 28 (c) 20 (d) 32

7. If 8051 micro controller is operating form 12 MHz clock then machine cycle takes:

   


 
 12MHz 8051 (c)

(a) 5 u sec (b) 1 u sec (c) 2 u sec (d) 10 u sec

8. Timer Mode-0 is called:   Mode-0 ( a )


(a) 04-bit timer mode (b) 13-bit timer mode

(c) 16-bit timer mode (d) 32-bit timer mode



9. A compiler is:  
  (d)

MS Electrical from LUMS 132


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

(a) Fast interpreter (b) Slower interpreter

(c) Assembler (d) Convert high level program to machine code

10. A byte correspondents to: 


 
____ 
 (b)

(a) 4 bits (b) 8 bits (c) 16 bits (d) 32 bits

10. Temporary store data in stack pointer instruction used:

  
   (b)

(a) MOV (b) Push & Pop (c) ANL (d) ORL

12. In flow chart rectangle block is used for: 


 (c)

(a) Sub routine (b) Decision (c) Process (d) Input output

13. Information stored and transmitted inside computer is:   

 (a)

(a) Binary form (b) ASCII code (c) Decimal form (d) Octal form

14. In 8051 micro controller chip which pin is used for supply voltage:



  8051 (b)

(a) 20 (b) 40 (c) 18 (d) 1

15. The program that deals with interrupt is called:   
  ( d )
(a) Linker (b) Base level (c) Interrupt level (d) Interrupt service routine

16. Arithmatic operator is:  



 (b)

(a) OR (b) MUL (c) MOV (d) CALL

17. The istruction that move data within internal memory is called:

 
  (b)

(a) Logical instruction (b) Data transfer instruction

(c) Arithmatic instruction (d) Program branch instruction



18. C++ language is a:   C++ (b)

(a) Low level language (b) High level language

(c) Assembly language (d) Machine language

19. In 8051 micro controller input output ( I/O's) ports are:

 (I/O's)   
 8051
 (b)

(a) 2 (b) 4 (c) 1 (d) 6

20. In 8051 micro controller port 2 consists of:  28051 (b)

(a) 1-8 pins (b) 21-28 pins (c) 10-17 pins (d) 29-37 pins
DAE/IA_2014

ELTR_363 MICROCONTROLLER PROGRAMMING AND APPLICATION

Time: 30 Minutes PART_A Marks:20

Q.1 Encircle the correct answer.     


  

1. How many bytes are there in 32 bits:    32 ( c )

(a) 1 (b) 2 (c) 3 (d) 4

MS Electrical from LUMS 133


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

2. A microcontroller normally has which of the following devices on-chip:

      


   (d)

(a) RAM (b) ROM (c) I/O (d) All of these

3. Which of the following register is bit addressable   


   (a)

(a) PSW (b) R0 (c) R4 (d) R7

4. The majority of the registers in 8051 microcontroller are:  


  
 8051 (c)

(a) 2 bits (b) 4 bits (c) 8 bits (d) 16 bits



5. In 8051, the program counter is ____ bits wide 
  
  
8051 (a)

(a) 16 (b) 8 (c) 4 (d) 2

6. A rectangle shape is used in flow chart for:

    (d)

(a) Decision (b) Terminal (c) Sub program (d) Process

7. What is the size of flag register in 8051:  8051


  (b)

(a) 2 bits (b) 8 bits (c) 16 bits (d) 4 bits

8. With each PUSH instruction, the stack pointer register:

 
  Push

 (d)

(a) Incremented by 1 (b) Decremented by 1 (c) Incremented by 2 (d) Decremented by 2

9. TF0 and TF1 are part of register____:   TF1 TF0 (c)

(a) Accumulator (b) B (c) TMOD (d) TCOM



10. 16 bits are equal to one:   
 16 (c)

(a) Mibble (b) Byte (c) Word (d) Double word

11. Which software is used for simulation:   


  (b)

(a) Keil (b) Proteus (c) Access (d) Excel

12. What is the size of on-chip ROM in the 8051: 


  8051 (b)

(a) 2 K byte (b) 4 K byte (c) 8 K byte (d) 16 K byte

13. How many pins are there for each I/O port in 8051:   I/O
   8051 (c)

(a) 32 (b) 16 (c) 8 (d) 4

14. Which of the following register is a 16 bit register: 


16 
 (a)

(a) DPTR (b) A (c) B (d) R7

15. Which pin is provided Vcc in the 8051:  Vcc8051 (d)

(a) 1 (b) 20 (c) 32 (d) 40

16. What value in decimal is equivalent to Hexa value FFH:  FFH 
   (b)

(a) 225 (b) 255 (c) 56 (d) 25

17. How many pins are assigned for I/O ports in 8051:  
I/O 

 8051 (c)

(a) 8 (b) 16 (c) 32 (d) 40

MS Electrical from LUMS 134


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

18. A timer can count upto the maximum value of:  


  
 

 (b)

(a) 55535 (b) 65535 (c) 25535 (d) 255

19. Which of the following number system is used in Assembly language:



 
   (d)

(a) Binary (b) Decimal (c) Hexa (d) All of these

20. How many register bank are there in the 8051  8051
  (a)

(a) 4 (b) 3 (c) 2 (d) 1


DAE/IIA_2014

ELTR_363 MICROCONTROLLER PROGRAMMING AND APPLICATION

Time: 30 Minutes PART_A Marks:20

Q.1 Encircle the correct answer.     


 
1. Microcontrollers are designed for:  
 (c)

(a) General function (b) Critical function (c) Specific function (d) None of these

2. Microcontrollers are generally used in: 



  (a)

(a) Embaded system (b) PLC's (c) Process control (d) None of these

3. Basic function of microcontroller & microprocessor is: 


   (b)

(a) Different (b) Same (c) No relation (d) None of these

4. 8051 microcontroller chip has:   8051


  (a)

(a) 40 pins (b) 50 pins (c) 32 pins (d) 43 pins

5. Number of interrupt sources in 8051 microcontroller are:  8051


   (a)

(a) 5 (b) 3 (c) 6 (d) 4

6. TMOD is:  
TMOD (a)

(a) 8 bit register (b) 16 bit register (c) 8 bit counter (d) 16 bit counter

7. Address bus is:  ( c )



(a) One way (b) Bidirectional (c) Tridirectional (d) None of these

8. 8051 can addresses: 


   8051 (a)

(a) 64 K bytes (b) 32 K bytes (c) 128 K bytes (d) 20 bits

9. Port registers of 8051 are:  8051 (d)

(a) 3 (b) 2 (c) 4 (d) 5

10. Every processor has its: 




 (d)

(a) Specific instruction set (b) Insturction set (c) Own programe (d) Both a & c

11. Addition of two operands is an: 


 (b)

(a) Logic instruction (b) Arithmetic instruction (c) Branch instruction (d) None of these

12. Branch instructions are of:    ( b )


(a) 3 types (b) 2 types (c) 4 types (d) 1 type

13. Capacity of memory is expressed in:     
  (d)

MS Electrical from LUMS 135


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

(a) Bytes (b) Bit (c) Nibble (d) K-Byte

14. Program is stored in: 


   ( b )
(a) DRAM (b) Program memory (c) SRAM (d) None of these

15. Speed of memory depends upon:   (a)

(a) Access time (b) Size (c) Time (d) None of these

16. 8-bit address bus can access memory locations:    8-bit


  (c)

(a) 00-FH (b) 000-FFF (c) 00-FFH (d) 01-54+5

17. Mnemonics are:   (b)

(a) Data item (b) Commands (c) Data (d) None of these

18. Machine language is:   (b)

(a) High level (b) Low level (c) Mid level (d) None of these

19. Assembler is:  


  (b)

(a) Machine (b) Software program (c) Main program (d) None of these

20. Serial communication interrupt is located at address: 


  (c)

(a) 003B (b) 003H (c) 0001B (d) 3 BH


DAE/IA_2015

ELTR_363 MICROCONTROLLER PROGRAMMING AND APPLICATION

Time: 30 Minutes PART_A Marks:20

Q.1 Encircle the correct answer.     


 
1. Number which shows memory location is:   
 (b)

(a) Data (b) Address (c) Bit (d) Byte

2. BIU stands for:  BIU (b)

(a) Binary input unit (b) Bus interface unit (c) BUS input unit (d) None of these

3. 1 Killo byte=_____ bytes   


______=  1 (d)

(a) 32 (b) 64 (c) 256 (d) 1024



4. Push instruction always transfers____bytes into stack: 


____  ( a )

(a) 2 (b) 4 (c) 8 (d) 16

5. Data movement instruction transfer data between: 


____ (c)

(a) Register to register (b) Register to memory (c) Both a & b (d) None of these

6. The binary equivalent of 85 is: ____   


  85 (c)

(a) 11001001 (b) 10011001 (c) 10101010 (d) 11111000

7. The first 640 KB of memory is called: 


 640 (b)

(a) Protected memory (b) ROM (c) Conventional (d) RAM

8. There are ____ interreup types in 8086:


 
    ____8086 (b)

(a) 200 (b) 256 (c) 356 (d) 300

9. The interrupts 20H to 3FH called _____ interrupt routines:  ____ 20H to 3FH
  (b)

MS Electrical from LUMS 136


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

(a) BIOS (b) DOS (c) C programming (d) None of these

10. Speed of processor in controller depends: 


 (b)

(a) MHz (b) Clock frequency (c) Time period (d) Binry numbers

11. MIPs stands for:   MIPs (c)

(a) Micro input system (b) Million input system

(c) Million of instructions per second (d) Millions of input

12. The clocking frequency of 8051 controller is: 


   8051
 (c)

(a) 3 MHz (b) 5 MHz (c) 12 MHz (d) 30 MHz

13. ASCII is ____ bit code: ____ASCII


 (c)

(a) 5 (b) 7 (c) 9 (d) 11

14. TEST instruction is AND instruction that effects only the:




   
____  AND TEST (c)

(a) Processor (b) Controller (c) Flag (d) None of these

15. There are ____ types of unconditional jump:    ____ (d)

(a) 2 (b) 3 (c) 5 (d) 7

16. NMI stands for:   NMI (d)

(a) Number of multiple inputs (b) Non multiple inputs

(c) Non maskable inputs (d) Non maskable interrupts



17. There are ____ segments in 8086 
    ____8086 (b)

(a) 2 (b) 4 (c) 6 (d) 8


 
18. How many active flags are in microprocessor:   
   8086 (d)

(a) 3 (b) 5 (c) 7 (d) 9

19. Buffer system is used for:  


 (d)

(a) Coding (b) Decoding (c) Multiplexing (d) De-multiplexing

20. How many register bank are there in the 8051  8051
  (a)

(a) 4 (b) 3 (c) 2 (d) 1


DAE/IIA_2015

ELTR_363 MICROCONTROLLER PROGRAMMING AND APPLICATION

Time: 30 Minutes PART_A Marks:20

Q.1 Encircle the correct answer.     


 
 
1. One of the following of a microcontroller is fixed capacity:      ( c )
(a) ROM (b) RAM (c) Both a & b (d) None of these

2. Given symbol ( <---- ) used in flow chart for:   <-----


 (b)

(a) Connector (b) Flow line (c) terminal (d) None of these

3. Connector are used in:   connector (d)

MS Electrical from LUMS 137


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

(a) Simple flow chart (b) Flow chart consisting of more than one pages

(c) Complex flow chart (d) Both b & c

4. 8051 microcontroller has internal RAM: RAM 8051 (c)

(a) 132 bytes (b) 64 bytes (c) 128 bytes (d) 256 bytes

5. Address bus is:  ( a )



(a) One way (b) Bidirectional (c) Tridirectional (d) None of these

6. Basically a microcontroller is:  


  (b)

(a) RISC (b) SISC (c) CIES (d) None of these


7. Capacity of memory is expressed in:   
  (c)

(a) Bytes (b) Bits (c) Nibble (d) K bytes

8. Address range of SFR of 8051 microcontroller is:  SFR 8051


 (c)

(a) 20H-2FH (b) 10H-20H (c) 80H-FFH (d) 30H-R0




9. In 8051, external memory is accessed by:     8051 (d)

(a) MOVC (b) MOVX (c) MOV (d) None of these

10. First part of an instruction is: 


 (b)

(a) Operand (b) Opcode (c) Directives (d) None of these

11. One of the following is directive:  


  (c)

(a) ADD (b) SUB (c) END (d) MOV




12. POP instruction is used to fetch data form:   POP (c)

(a) Accumulator (b) PC (c) Stack (d) IR

13. A loop in which reptitions are not defined:  


 repition (b)

(a) Infinite loop (b) For loop (c) While loop (d) Do while do loop

14. PUSH instruction is used to:  PUSH (b)

(a) Store data in accumulator (b) Store data in stack (c) Store data in PC (d) None of these

15. INT0 and INT1 are:  


INT1INT0 (a)

(a) Internal interrupts (b) External interrupts

(c) External hardware interrupts (d) Serial communication interrupts

16. Mouse is a type of ____ peripheral device:  ____ 


   (d)

(a) External (b) Input (c) Internal (d) Both a & b

17. Types of digital interfaces are:    (a)

(a) 3 (b) 2 (c) 4 (d) 5

18. Microcontroller are used: 


 (b)

(a) Speed control system (b) Inverters (c) Power suplies (d) All of these

19. Branch instructions are of:   ( b )



(a) 3 types (b) 2 types (c) 4 types (d) 1 type

MS Electrical from LUMS 138


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

20. TMOD is TMOD (c)

(a) 8 bit register (b) 16 bit register (c) 8 bit register (d) None of these
DAE/IA_2016

ELTR_363 MICROCONTROLLER PROGRAMMING AND APPLICATION

Time: 30 Minutes PART_A Marks:20

Q.1 Encircle the correct answer.     


 
1. 1 Killo bytes are equivalent to:  



 (d)

(a) 240 bytes (b) 230 bytes (c) 220 bytes (d) 210 bytes

2. Which of the following is used to carry information in & out of a CPU:

CPU
  CPU  (a)

(a) Data bus (b) Control bus (c) Address bus (d) Both a & b

3. The ASCII code for B is:  ASCII B (c)

(a) 60C (b) 0011 (c) 42H (d) 1100

4. A microcontroller has which of the following devices on-chip:

      


   (d)

(a) RAM (b) ROM (c) I/O (d) All of these

5. The vast majority of registers in 8051 are:    


  8051 (a)

(a) 8 bits (b) 16 bits (c) 32 bits (d) 64 bits

6. The flag register in the 8051 is called:  


  8051 (b)

(a) R0 (b) PSW (c) A (d) B

7. With each POP instruction, the SP register is decreased by :

 ( b )
SPPOP
(a) 1 (b) 2 (c) 3 (d) 4

8. The LCALL instruction is a ____ bytes instruction: 


 LCALL (c)

(a) 1 (b) 2 (c) 3 (d) 4

9. Which instruction combines decrement & jump both actions:

    jump decrement  (b)

(a) LJUMP (b) DJMP (c) JNC (d) JZ

10. What is the size of the SP register:  


  
  (b)

(a) 16 bits (b) 8 bits (c) 4 bits (d) 2 bits



11. Each port of 8051 has ____ bits:      8051
____ (c)

(a) 32 (b) 16 (c) 8 (d) 4

12. Which port of 8051 needed pull-up resistors to function as an I/O


 pull up
I/O 8051 (d)

(a) P3 (b) P2 (c) P1 (d) P0

MS Electrical from LUMS 139


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

13. What is the location of bytes of RAM which are bit addressable:    

 
 (c)

(a) 3FH-7FH (b) 20H-3FH (c) 20H-2FH (d) 00-1FH



14. Each timer of 8051 is ____ bits wide:   ____
  8051
 (c)

(a) 4 (b) 8 (c) 16 (d) 32

15. Which pins are used for crystal oscillator in the 8051: 

   8051
 (a)

(a) 18-19 (b) 10-11 (c) 30-31 (d) 39-40

16. TF0 & TF1 are part of register:   TF1 TF0 (d)

(a) DPTR (b) PC (c) TMOD (d) TCON

17. Beside reset, how many interrupts do we have in the 8051:  


 8051 (c)

(a) 3 (b) 4 (c) 5 (d) 6

18. How many pins in 8051 are used for I/O port pins  I/O   8051
 (d)

(a) 20 (b) 16 (c) 40 (d) 32

19. Which instructions are translated by the assembler in to machine code:

 
    (b)

(a) Pseudo instruction (b) Instruction mnemonics (c) Assembler directive (d) None of these

20. How many serial ports are in 8051:  8051 (d)

(a) 4 (b) 3 (c) 2 (d) 1


DAE/IIA_2016

ELTR_363 MICROCONTROLLER PROGRAMMING AND APPLICATION

Time: 30 Minutes PART_A Marks:20

Q.1 Encircle the correct answer.     


 

1. How many bits are there in 16 bits:  
  16 ( b )

(a) 1 (b) 2 (c) 3 (d) 4

2. ROM is a: ROM (c)

(a) Read/Write memory (b) Read only memory (c) Non volatile memory (d) Only write memory

3. Which device has not available in microcontroller chip:    


  (d)

(a) RAM (b) ROM (c) I/O (d) Scaner

4. Which of the following register is bit addressable:   


   (a)

(a) PSW (b) R0 (c) R4 (d) R7



5. In RAM address rangge of SFR banks are:  
  RAM (b)

(a) 00H-77H (b) 00H-FFH (c) 80H-87H (d) 80H-FFH

6. 
In 8051 microcontroller on chip crystal oscillator frequency    
    8051
 (a)

(a) 10 MHz (b) 20 MHz (c) 30 MHz (d) 50 MHz

7. A rectangle shape is used in flow chart for:

   (d)

MS Electrical from LUMS 140


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

(a) Decision (b) Terminal (c) Sub program (d) Process

8. Long addressing is used whith the instruction: 


   (a)

(a) L CALL (b) LOOP (c) PUSH (d) POP

9. In 8051 microcontroller interrupts are:  8051


  (a)

(a) 6 (b) 2 (c) 3 (d) 4

10. In 8051 parallel ports are:   I/O8051 (d)

(a) 1 (b) 2 (c) 3 (d) 4

11. A serial interface is:  


 (b)

(a) Parallel interface (b) RS-232 interface (c) Printer interface (d) Modern interface

12. Timer Mode-0 is called:   Mod 0 ( c )


(a) 4 bit timer mode (b) 13 bit timer mode (c) 16 bit timer mode (d) 32 bit timer mode

13. The 8-bit binary number ( 0000 0100 ) represent:  ( 0000 0100 )
 
 (c)

(a) 1 (b) 3 (c) 4 (d) 5

14. In microcontroller data bus is:  (b)

(a) Unidirectional (b) Bidirectional (c) Both a & b (d) No direction

15. In 8051 which pin is used for Vcc: Vcc 8051 (d)

(a) 1 (b) 10 (c) 30 (d) 40

16. Logical operator is: 


 (c)

(a) ADD (b) MOV (c) XOR (d) INC

17. Beside reset, how many interrupts do we have in the 8051:  


 
 
16 bit (c)

(a) 55635 (b) 46935 (c) 65535 (d) 255

18. In 8051 microcontroller port 2 consists of:   port-28051 (b)

(a) 1-8 pins (b) 21-28 pins (c) 10-17 pins (d) 29-37 pins

19. How many register banks in 8051  8051 (b)

(a) 2 (b) 4 (c) 5 (d) 6

20. Temporary storage data in stack pointer instruction used:



   (b)

(a) MOV (b) Push & Pop (c) ANL (d) INC

MS Electrical from LUMS 141


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

ELTR_343
( Third year )

MICROCONTROLLER

PROGRAMMING & APPLICATIONS

PART_B

Long Questions form 5 year

Past Papers

MS Electrical from LUMS 142


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

DAE/IA_2013
  
    2(a) 


   2(b)


       3(a) 

 
  3(a)

 
   immediate 4(a) 

  
   
  4(a)

 square 10KHz


P1.00 
 

 5(a) 

 
   5(a)

 ADC0804 
   8051 
     
 6 

DAE/IIA_2013
(5) 

 2(a) 

(5)  
  2(b)

(5)    Buses


  3(a) 

(5)  
  3(a)

(5)  45H40H 55H 


   

 4(a) 

(5) 
   4(a)

(5)   ( TCON )


   ( TMOD ) 5(a) 

(5)    LM34


   5(a)
 

( 10 )   
   LEDs 
  
  1 6 

DAE/IA_2014
( 10 )    
  
  2 

(5)    


   (a) 3 

(5)  
Buses (b)

(5)     (a)


 4 

   peripheral (b)
(5)   
(5) 
    (a) 5 

(5) 
   
 11.0592 Hz  8051 (b)

( 10 ) 
  
  
   6 

DAE/IIA_2014
( 10 )    
  
   ( 2 ) 

(5)  (a)
   ( 3 ) 

(5)  
   
 (b)

(5)   Buses (a) ( 4 ) 

(5) 
   (b)

MS Electrical from LUMS 143


ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

( 10 )  
    ( 5 ) 

( 10 )    
   ( 6 ) 

DAE/IA_2015
( 10 ) 
       ( 2 ) 

( 10 )  
  ( 3 ) 

( 5+5 )   
 ( 4 ) 

EEPROM (b) UVEPROM (a)

( 10 )    ( 5 ) 

( 10 ) 
 PWM ( 6 ) 

DAE/IIA_2015
Q.2 (a) Describe the need of programming microcontroller. 
 

(b) Discuss the characteristics of micorcontroller.   
Q.3 Explain the Instruction set of 8051 microcontroller with the help of example.

 
   8051
Q.4 Write a note of the following  

(1) Data Transfer Instruction (2) Bit Orinted Instructions

(3) Logic Instructios. (4) Arithmetic Instructions

Q.5 What do you mean by interrupts and explain its types.      
  

 
Q.6 Describe the classification of Peripherals devices.    
 
  
DAE/IA_2016
Q.2 Draw the block diagram of 8051 microcontroller and explain it.

   
  
  8051 (10)

Q.3 (a) Explain different parts of flow charts.   


  (5)

(b) Discuss buses in microcontrollers.  


 (5)

Q.4 Explain different addressing modes.   


   (10)

Q.5 (a) Discuss the role of interrupts in programming.  


   (5)

(b) Describe requirements for connection support chip.     
  (5)
Q.6 Explain microcontroller system application in Electroncis system.

 
   (10)

DAE/IIA_2016
Q.2 Draw the block diagram of 8051 microcontroller and explain its each block.

 
  
     8051
Q.3 (a) Describe the need of programming in microcontroller.   


(b) Describe the different symbols used in flow chart.  
   
Q.4 (a) Describe the different types of interrupt. 
  
MS Electrical from LUMS 144
ELTR-363 ( Microcontroller Programming and Applications ) By Amir Amin 0333_4296968

(b) Describe buses in microcontroller.  




Q.5 (a) Write a program to copy the value 55H into RAM memory location 40H using direct addressing

mode with a loop.

45H 55H  
  


(b) Find the timer's clock frequency and its time period for 8051 based system, with the 16MHz crystal

frequency.


    16 MHz
  8051
Q.6 Draw and explain the AC phase control circuit using microcontroller based Triac.

  
  AC 
 
DAE/IA_2017
Q.2 Explain in detail communication unit. 
 
Q.3 Write note on the following.  

(a) Logic Instruction (b) Data transfer instruction

Q.4 Explain in detail memory interfacing in Microcontroller.   


Q.5 Explain LCD interfacing with 8051.   LCD 8051
Q.6 Write note on the following.  

(a) RS232 (b) MAX 1112

MS Electrical from LUMS 145


  
DAE Electronics.
B-Tech Honours in Electronics & Communication.
Electrical Engineering from UMT.
MS Electrical Engineering from LUMS...
         

Contact: 0333-4296968
Our Publication are

Electronics 1st Year


ELTR 114 Electrical Circuits
ELTR 123 Electronics Devices
Comp 112 Computer Fundamentals

Electronics 2nd Year


ELTR 212 Propagation of EM Waves
ELTR 225 Analog Electronics
ELTR 233 Electrical Instruments & Measurements
ELTR 243 Electrical Machines
ELTR 253 Communication Systems
ELTR 264 Digital Electronics

Electronics 3rd Year


ELTR 314 Computer Architecture
ELTR 343 Industrial Electronics
ELTR 353 Power Electronics
ELTR 363 Microcontroller Programming and Applications

Electrical 1st Year


ET 115 Principles of Electrical Engineering

Electrical 2nd Year


ET 213 D.C. Machines & Batteries

ET 223 Electrical Instruments & Measurements

ET 233 Utilization of Electrical Energy


ET 263 Basic Electronics

Electrical 3rd Year


ET 343 Telecommunication
ET 363 Digital & Industrial Electronics

AMG Technical Academy, A House of Quality Notes

You might also like