Embedded Interview Questions

1)Difference between Microprocessor(CPU) and Microcontroller(System on chip)?

 a) The microprocessor is the heart of the computer system.
       The microcontroller is the heart of the Embedded system.

  b) Microprocessor is a CPU that doesn't come with inbuilt peripherals.
        The microcontroller is a Chip which contains inbuilt CPU and other peripherals
        like  RAM, ROM, I/O, UART, TIMER, etc.,

  c)Since Memory and I/O has to be connected externally the circuit becomes large.
     Since Memory and I/O are present Internally, the circuit is small.

  d)Cost of the entire system Increases.
      Cost of the entire system is low.

  e) Power Consumption is more.
      Power Consumption is less.

  f) Heat dissipation is more.
      Heat dissipation is less.

  g) The microprocessor is based on the Von-Neumann model where program and data are
      stored in the same memory location.
      Microcontrollers are based on Harvard Architecture where program memory and
      data memory is Separate.

 h) Used by personal computers and laptops
      Used by microwave ovens and washing machines.

 I)Ex: -8085,8086, i3, i5, i7
    Ex: -8051, AVR, PIC, ARM-based controllers

2)Difference between RAM(Data Memory) and ROM(Program/Code Memory)?

a) Random Access Memory
    Read-Only Memory

b) RAM is Volatile memory which could store the data as long as
     the power is supplied.
     ROM is Non-Volatile memory which could retain the data even
     when power is turned off.

c)It is a high-speed memory
     It is much slower than RAM.

d)Temporary Storage
      Permanent Storage

e) Store data in MBs.
     Store data in GBs.

f) Writing data is faster.
      Writing data is slower.

g) Used in normal operations.
     Used for the start-up process of the computer.

h) Stores during and after processing
       Store by Manufacturer

i)Very fast but uses a lot of Power
     Fast but uses very little power

j) Costlier
    Cheaper than RAM

k) RAM is in the form of a chip
    ROM is generally optical drivers made of magnetic tapes.

l)Static RAM, Dynamic RAM
    PROM, EPROM, EEPROM.

3)Difference between C Language and Embedded C?

 a)A type of high-level language
    Nothing but an extension of C.

 b)It is used for computer programming(or)Application Development
    It is used for Microcontroller programming(or)for Microcontroller software
    development.

 c) Optimization is normal.
    High level of Optimization

 d) An Operating System is essential to function.
    Can Work with (or) Without an Operating System

 e)The native compiler is required to compile C program
    Cross Compiler is required to compile Embedded C program

 f)We can't Access physical memory directly
    We can Access physical memory directly

 g)Size of executable i.e. a. out is larger than hex file
    Size of hex file is smaller than a. out

 h)Not hardware-dependent
   Hardware dependent programming language

i)Cannot communicate with the Motherboard Peripherals
   Can Communicate all on-chip Peripherals of Micro Controller like RAM,
    Flash Memory, Timer, UART, I/O,etc.,

4)Difference between CISC and RISC?

 a)Complex Instruction Set Computing
     Reduced Instruction Set Computing

  b)Complex Instruction, hence Complex Instruction decoding
      Simplex Instruction, hence Simple Instruction decoding

  c)Multi Clock Cycled Instructions
     Single Clock Cycled Instructions

  d)Focus on Hardware
      Focus on Software

  e)Code size is Small
     Code size is Large

  f)Instruction takes more than One Cycle
    An Instruction execute in Single Clock Cycle

  g)More number of Logic gates Inside CPU/Processor
      Less number of Logic gates Inside CPU/Processor

  h)Power Consumption will be more
     Less Power Consumption

  i)Heat Dissipation more
      Less Heat Dissipation

   j)Cooling system Required
        The cooling system not required

   k) Computers/Laptop, 8085, 8086, Intel Processors,etc...,
       Mobile phones, ARM, AVR, PIC..,

5)Difference between Von-Neumann and Harvard?

 
   a) It uses the same physical memory address for Instructions and data.
      It uses separate memory addresses for Instructions and data

   b)The processor needs two clock cycles to execute an Instruction
      The processor needs one clock cycle to complete an Instruction

  c)Simpler control unit design and development of one is cheaper and faster
     Control unit for two buses is more complicated which adds to the development cost

  d) Data transfers and Instruction fetches cannot be performed simultaneously.
     Data Transfers and Instruction fetches can be performed at the same time

  e)Used in Personal Computers, Laptops
     Used in Microcontrollers and signal processing

  f)8085,8086..i9,ARM processors
    8051,AVR,PIC

  g)Decrease Disize of IC
     Increase Disize of IC



6)What is the use of Volatile Keyword?

    a) Volatile is used to prevent the compiler to optimize any variable.

    b)When any variable is used frequently, the compiler optimizes it and keeps
       the variables in his memory to serve its value faster to the program.


7)which place to use the Volatile keyword?

   a) Accessing the memory-mapped peripherals register (or) hardware status register.

   b) Sharing the global variables (or) buffers between the multiple threads.

   c) Accessing the global variables in an interrupt routine (or) signal handler

8)What is the use of having  Const qualifier?

1)The Const qualifier  a specific parameter (or) variable as a read-only attribute
    to the function (or) to the entire program.

 2)This can come in handy when we are dealing with static data inside the function
      and in a program.

9)Difference between Const and Volatile Qualifiers?

a)The const keyword is compiler enforced and says that the program could
       not change the value of the object means it makes the object non
       modifiable type.

b)Volatile prevents any compiler optimization and say that the value of the object
    can be changed by  something that is beyond the control of the program and so
    that compiler will not make any assumption about the object.

10)Can a variable be both const and volatile?

  1) Yes, we can use both constant and volatile together.

  2)one of the greatest use of volatile and const keyword together is at the time
     of accessing the General Purpose Input Output registers.

  3)In the case of General Purpose Input Output its value will be changed by the
     external factors, if it is configured as an input.

  4)In that situation, volatile plays an important role and ensures that 
       the compiler always read the value from the GPIO address and avoid to
     make any assumption.

 5)After using the Volatile keyword, you will get proper value whenever you are
    accessing the  ports but still here is one more problem because the pointer is
    not const type so it might be your program change the pointing address of the
    Pointer.so we have to create a constant pointer with the volatile keyword.

 Ex:- int volatile *const  port register;
          the port register is a constant pointer to a volatile integer

11)Why do we need an Infinite loop in Embedded systems?

The infinite loops are coded in to give a delay (or) sleep to the program
 execution for a specific amount of clock ticks.

   Ex;- while();,for();

12)What is an Interrupt?

An interrupt is a signal to the CPU, that causes the CPU to temporarily work on a
 different task and then later return to its previous task.

13)What is an ISR?

 1) An ISR refers to the Interrupt Service Routines. These are procedures stored at
     Specific memory addresses which are called when a certain type of interrupt
      occurs.

  2)An ISR is an interrupt handler, a callback subroutine which is called when an interrupt
      is encountered.

14)What is Interrupt Latency?

1) Interrupt Latency is the time required for an ISR responds to an Interrupt.

2)Interrupt Latency is the number of clock cycles that are taken by the processor
     to respond to an Interrupt request.

3)This number of the clock cycles is count between the assertions of the interrupt
     request and the first instruction of the interrupt handler.

15)What is Flash Memory?

1)      Flash Memory is a non-volatile memory chip used for storage and for
transferring data between a personal computer and digital devices.

 2) A kind of memory that retains data in the absence of a power supply.

16)What is the Watchdog Timer?
 
 1)The watchdog timer is hardware that automatically Initiates a system reset if the
     the main program neglects to service it.

 2)It is often used to reset an Embedded device that hangs because of software (or)
     hardware malfunction.

17)What is the Start-up Code?

    A Start-up Code is called prior to the main function, it creates a basic platform
    for the application.

       It is a small block of code that is written in Assembly Language.

       There are the following parts of the start-up code

          a) Declaration of the stack area.

          b)Declaration of the Heap area

          c)Vector table

          d)Reset Handler code

          e)other exception handler code

18)Difference between Interrupt and Polling?
     
      a) In Interrupt, the device notices the CPU that it requires its attention.
         In polling, CPU steadily checks whether the device needs attention.

      b) An Interrupt is not a protocol, It’s a hardware mechanism.
         Whereas It isn't a hardware mechanism, It’s a protocol.

      c) In Interrupt, the device is serviced by Interrupt handler.
         While in polling, the device is service by CPU.

      d) The interrupt can take place at any time.
         Whereas CPU steadily ballots the device at regular (or) proper Interval.

     e) In Interrupt, it will not waste the CPU time.
        In Polling method, it wastes the CPU time.

19)Difference between Timer and Counter?

a)      1)The timer is Inbuilt peripheral of Microcontroller which counts Internal
           Clock Pulses.

        2) Timers to generate a Time delay.

   Applications: - 1) Generating a frequency.

                              2)All I/O Interfacing Programs

                              3) Time-Slice of the OS depends on Timer.

  b)Counter is Inbuilt peripheral of Microcontroller which counts external clock
       pulses (external    events).

   Applications:-1)Visitors Counter

                           2)Speedometer

                           3)Finding frequency of the device

20)Difference between Serial Communication and Parallel Communication?

 
Serial  Communication
Parallel  Communication
Data Transmission Speed
Slow
Comparatively fast
Number  of Communication      
Link used   
Single
Multiple

Cost
Low
High
Cross Talk                                      
Not Present
Present
Suitable for                                    
Long Distance
Short Distance
System Up-gradation
Easy
Quite Difficult
Mode of Transmission                  
Full Duplex
Half Duplex

21)Difference between Synchronous Communication and Asynchronous Communication?

      a) Communication is done by a shared clock.
           There is no common clock signal between sender and receivers.

      b) Sends data in the form of blocks (or) frames.
           Sends 1byte (or) character at a time
.
     c)Synchronous communication is fast
        Asynchronous communication is slow

     d) Synchronous communication is costly.
         Asynchronous Communication is Economical.

     e)Less Overhead
        Overhead due to start and stop bit.

     f) In Synchronous Communication, the time interval of transmission is Constant.
         In Asynchronous Communication time interval is not constant, It is random.

     g) There is no gap present between data.
         There is a gap Present between data.

     i)Ex;-I2C,SPI
        Ex;-RS232,RS485 

22)Difference between Bit Rate and Baud Rate?

     a) Bit Rate is the number of bits per second.
          Baud Rate is the number of signal units per second

     b) It determines the number of bits traveled per second.
        It determines how many times the state of a signal is changing

     c) Cannot determine the Bandwidth.
         It can determine how much bandwidth is required to send the signal.

     d)Bit Rate=Baud Rate (x) the number of bits per signal unit
        Baud Rate=Bit rate /the number of bits per signal unit

23)Difference between JUMP and CALL?
 
     a)Program Control is Transferred to a memory location which is in
         the main program.
         Program Control is Transferred to a memory location which is not a
         part of the main program.

     b)Immediate Addressing Mode
        Immediate Addressing Mode +Register Indirect Addressing Mode

     c) Initialization of Stack Pointer is not Mandatory.
        Initialization of Stack Pointer is Mandatory.

     d)Value of Program Counter is not Transferred to stack
         Value of Program Counter is Transferred to stack.

     e)After JMP, there is not RET Instruction
        After CALL, there is a random Instruction

24)Difference between Native Compiler and Cross Compiler?

     1) The Compiler used to compile a source code for the same type of platform only.
          The Compiler used to compile source code for different kinds of platforms.

     2) A Native Compiler generates codes for the same machine (the host).
        A Cross Compiler generates code for another machine (the target).

     3)Ex:-Turbo C, GCC
        Ex:-C51,ARMCC


25)What is an Embedded System?

   1)An Embedded System is a combination of Computer Hardware and Software,
      either fixed in Capability (or) Programmable, designed for a specific function
      (Or) functions within a larger system.

   2)All Computing Systems other than General Purpose computer are
       Embedded systems.

   3)Industrial Machines, agricultural and Process industry devices , automobiles,
       medical equipment Cameras, household appliances, airplanes, vending
       machines and toys, as well as mobile devices are possible locations
       Of Embedded systems.

26)What do you Understand by a Micro Controller?

  Microcontroller is a self-contained device with Peripherals, Memory and
   an A processor that can be used as an Embedded System.

27) What is Instruction and Instruction Set?

  The Instruction Set also called ISA(Instruction Set Architecture), is a part of
   A computer that Pertains to Programming, Which is basically machine language.

   The instruction set provides commands to the processor, to tell it what it needs to do.

28)What are the features of the 8051 Micro Controller?

   
     a) Intel Family.

     b) 8051 is an 8-bit Micro Controller.

     c) Follows Harvard Architecture.

     d) Based On Complex Instruction Set Computing (CISC).

     e) Registers, Arithmetic Logical Unit Processing Capacity is 8-bits.

     f) 8051 is available in 40 Pin Dual In-Line Package (DIP).

     g) 8051 has 4K Bytes of Read-Only Memory (ROM).

     h)8051 has 128 bytes of Random Access Memory(RAM) and 128 bytes of
         RAM is reserved for Special Function Registers (SFR's).

     i) 8051 has 32 I/O Pins, divided into 4 I/O Ports (P0 to P3).

     j) 8051 has Full Duplex UART (For Serial Communication).

    k)It has two 16 bit Timers(Used to generate precise delay) /
       Counters (Used to count external event).

    l) Size of Address Bus is 16 bit (2^16 Memory Locations).

   m) Size of Data Bus is 8 bit (Access 8 bits of data in one Operation).

    n)It Supports Six Interrupts

       1)RESET-Non Maskable Interrupt

       2) Remaining Five are Maskable Interrupts (Which can be ignored by CPU).

   o)No Watch Dog Timer

   p)It can execute 1 million one-cycle Instructions per second with a clock
     frequency of 12 MHZ.

   q) It consists of a 16-bit Program Counter (PC) and Data Pointer (DPTR).

   r) It also consists of 32 GPR each of 8bits.

   s) Contains a Micro Coded Processor.

   t) 8051 Reset is Active High.

   u)One Machine Cycle of 8051 contains (or) Consists of 12 Clock Cycles
      and hence is typical of 1 Micro Second.


29)What is the Program Counter Register of 8051?

     a) It is a 16-bit register.

     b) It contains the address of the next instruction.

     c) It is Incremented as soon as every instruction byte is fetched.

30)What is the Stack Pointer Register of 8051?
 
      a) It is an 8-bit register.

      b) It contains the address of the top of the stack.

      c) It is incremented during the push.

      d) It is decremented during the pop.

      e) Its default value is 07H.

      f) The size of the stack pointer is 1 byte.

      g) 8051 stack is a type of up growing stack.


31)What is the significance of the Accumulator register in 8051?
 
   a) It holds the first operand and the result in most arithmetic and logical operations.

   b)It is the  only register that can be used to transfer DATA with external RAM
       and ROM using instructions like MOVX and MOVC.


32)What is the Data Pointer Register of 8051?

      a) It is a 16-bit register.

      b) Combination of DPL and DPH.

      c) Few Instructions are having in 8051 they use DPTR.

      d) External RAM operations use DPTR.

      e)Flash Memory read Operation. (CPU cannot write into Flash Memory)

33)What is Opcode?

 Every Instruction of the Microcontroller has its unique number called an opcode.
 Size of the opcode depends on Microcontroller.

34)What is an Instruction Cycle, Machine Cycle, and T-State?
 
     a)Total Process of fetching, decoding and executing an instruction is
         instruction cycle.

      b) One complete operation of the system bus is the Machine cycle.

      c) One Clock Cycle is T-State.

     d) Instruction Cycle has several machine cycles.

     e) The Machine Cycle of 8051 has 12 Clock Pulses (or) 6 T-States.

35)Difference between Bit Banging Method(I/O Programming)and
   Peripheral Method(Pin numbers are fixed)?

1) It is a software method of Implementing the protocol instead of using
       dedicated hardware.

      It is a hardware method of Implementing the protocol. Here dedicated
      hardware is used to Implement protocol.

  2) Code Size will Increase in the Bit Banging Method.

36)Difference between Power-on Reset and Brown on Reset in MicroController?

1)a)A Power-on Reset generator is a microcontroller (or) microprocessor peripheral 
       that generates a  signal when power is applied to the device. It ensures that the
       device Starts operating in a known state.

  b)A Brown on Reset is a circuit that  causes a computer processor to reset (or)
     reboot  in the event of a brownout, which is a significant drop in the power
     Supply output voltage. Brownouts can occur for  brief intervals (or) over
     extended periods.

37)What are TTL Voltage Levels?

 a)A TTL input signal is defined as "low" when between 0 V to 0.8 V with respect
      to ground terminal

  b)A TTL input signal is defined as "high" when between 2 V to 5 V.

38)What is the voltage level of RS232 serial communication?

1)A logic high ('1') is represented by a negative voltage from -3 V to  -25 V .

2)A logic low ('0') is represented by a positive voltage from +3 V to +25 V.

39)Difference between AT89S52 and AT89S51?

a) In AT89S52 all the ports are dual functionality.
    In AT89S51 only three ports are dual functionality.

b) In AT89S52 ----- 8K bytes ROM (Flash).
     In AT89S51 ----- 4K bytes ROM (Flash).

c) In AT89S52 ------ 256 bytes RAM.
    In AT89S51 -------128 bytes RAM.

d)In AT89S52 ------  3 16-bit Timers/Counters
   In AT89S51 ------- 2 16-bit  Timers/Counters

e)In AT89S52------  8 Interrupt Sources
    In AT89S51 ------ 6 Interrupt Sources

40)Difference between 8051 and AT89S52?

a) Designed by Intel.
   Designed by Atmel.

b) 4 KB of  ROM
    8KB  of Flash Memory

c) 128 bytes of User RAM.
    256 bytes of user RAM.
d)It has two timers.
   It has three timers.

e)No watchdog Timer
  Watchdog Timer

f)Six Interrupts
  Eight Interrupts

41)Difference between Sub Routine and Interrupt Service Routine?

a) The subroutine is a function that runs when you call it.

b) This occurs at Specific and Predetermined locations in the main routine.

c) Software Initiated.

d) Requests can come Expectedly.

e) It is a small code within a big piece of code.


a) Interrupt Service Routine is also called an Interrupt Handler.

b) Can ask for service without any Prior Notice.

c) Hardware Initiated.

d) The request may come Unexpectedly.

e)Whenever an Interrupt occurs, the controller completes the execution of the current
    Instruction and starts the execution of ISR.

f) ISR tells the processor or controller what to do when the interrupt occurs.

g) It is a software process invoked by an interrupt request from a hardware device.

h) It handles the request and sends it to the CPU, interrupting the active process.

i) When the ISR is complete, the process is resumed.



42)What is Super Loop in an Embedded system?

Super loop is an infinite loop which is suitable only in  embedded c programming because there you have to run your code for a long time and wants explicitly terminate when the behavior is changed for your system.

 

MCU is a device which runs continuously or better, it executes instructions when power is on (in general).

So while loop is here to force MCU to do something, even if the loop is empty, it will just circle around.

But it must do something as it is not the same as PC program where you have return at the end of the main function.

 

If you wouldn't have a super loop, then MCU can get instruction from FLASH/RAM (whatever...) and do something stupid things as MCU doesn't know what it is executing. It just executes the code you provide him.

 

By using a super loop, you guarantee MCU won't just uncontrollable execute some instructions and maybe go to the fail-safe area. 


  

 

while(1)

{

// Your code

// exit condition 

}

 for(;;) 

{

}