embedded system Questions with answers

Embedded System Interview Questions with Answers

This article is mainly focused on the most repeatedly asked embedded system interview questions. If you are looking for “embedded system interview questions” or  “simple questions on embedded systems”, then you at the right place.

Here I have tried to create some collection of “embedded system interview questions with answers” that might ask by your interviewer. These embedded system questions not only for fresher but also good for the experienced person.

I hope these embedded system interview questions with the answer will be helpful. If you have any other important questions relate to the embedded systems and concepts or want to give the answer to any mentioned embedded systems interview questions, then please write in the comment box. It is helpful to others.

 

Q) What are the components of an embedded system?

Below I am mentioning essential components of the embedded system,

  • Power supply.
  • Processor.
  • Memory.
  • Timers-Counters.
  • Communication Ports.
  • I/O circuits.
  • Application-Specific Circuits.
  • Assembler.
  • Emulator.
  • Debugger.
  • IDE and Compiler.

 

Q) Difference between RISC and CISC processor?

The RISC (reduced instruction set computer) and CISC (Complex instruction set computer) are the processors ISA (instruction set architecture).

There is the following difference between both architecture:

                  RISC CISC
Acronym It stands for ‘Reduced Instruction Set Computer’. It stands for ‘Complex Instruction Set Computer’.
Definition The RISC processors have a smaller set of instructions with few addressing nodes. The CISC processors have a larger set of instructions with many addressing nodes.
Memory unit It has no memory unit and uses separate hardware to implement instructions. It has a memory unit to implement complex instructions.
Program It has a hard-wired unit of programming. It has a micro-programming unit.
Design It is a complex compiler design. It is an easy compiler design.
Calculations The calculations are faster and precise. The calculations are slow and precise.
Decoding The decoding of instructions is simple. Decoding of instructions is complex.
Time Execution time is very less. Execution time is very high.
External memory It does not require external memory for calculations. It requires external memory for calculations.
Pipelining Pipelining does function correctly. Pipelining does not function correctly.
Stalling Stalling is mostly reduced in processors. The processors often stall.
Code expansion Code expansion can be a problem. Code expansion is not a problem.
Disc space Space is saved. Space is wasted.
Applications Used in high-end applications such as video processing, telecommunications, and image processing. Used in low-end applications such as security systems, home automation, etc.

Images Courtesy: ics.uci.edu

 

Q) What is the difference between Von-Neuman and Harvard Architecture?

VON NEUMANN ARCHITECTURE

HARVARD ARCHITECTURE

Von-Neumann architecture is an ancient computer architecture based on the stored-program computer concept. Harvard architecture is a modern computer architecture based on the “Harvard Mark I” relay-based model.
The same physical memory address is used for instructions and data. A separate physical memory address is used for instructions and data.
A common bus is used for data and instruction transfer. Separate buses are used for transferring data and instruction.
The processing unit would require two clock cycles to complete an instruction. The processing unit can complete instruction in one cycle if appropriate pipelining plans have been set.
It is cheaper in cost. It is costly than Von-Neumann architecture.
CPU cannot access instructions and read/write at the same time. CPU can access instructions and read/write at the same time.
It is used in personal computers and small computers. It is used in microcontrollers and signal processing.

 

Q) What’s the difference between a microcontroller and a microprocessor?

The below table contains some common differences between Microprocessor and Microcontroller (Microprocessor vs. Microcontroller).

Microprocessor

Microcontroller

A microprocessor has only a CPU inside them in one or a few Integrated Circuits. Eg, 8085, 8086 etc A microController has all the things like RAM, ROM, and timer ..etc on the chip. Eg. 8051, PIC series, etc.
Because it has only a processor, so memory and I/O components need to be connected externally. It is a complete package. You only need to attach require external peripheral like LED, LCD, etc. The microController has a processor along with internal memory and I/O components.
Memory and I/O has to be connected externally, so the circuit becomes large. Memory and I/O are already present, and the internal circuit is small.
You can’t use it in compact systems You can use it in compact systems.
Cost of the entire system is high Cost of the entire system is low
Due to external components, the total power consumption is high. Therefore, it is not ideal for the devices running on stored power like batteries. As external components are low, total power consumption is less. So it can be used with devices running on stored power like batteries.
Most of the microprocessors do not have power-saving features. Most of the microcontrollers offer power-saving mode.
It is mainly used in personal computers. It is used mainly in a washing machine, MP3 players, and embedded systems.
Microprocessor has a smaller number of registers, so more operations are memory-based. Microcontroller has more register. Hence the programs are easier to write.
Microprocessors are based on the Von Neumann model Micro controllers arc based on Harvard architecture
It is a central processing unit on a single silicon-based integrated chip. It is a byproduct of the development of microprocessors with a CPU along with other peripherals.
It has no RAM, ROM, Input-Output units, timers, and other peripherals on the chip. So the circuit connection will be complicated. It has a CPU along with RAM, ROM, and other peripherals embedded on a single chip. All most all require things on single-chip so circuit connection will be easy and a newbie easily interface I/O devices.
It uses an external bus to interface to RAM, ROM, and other peripherals. It uses an internal controlling bus.
Microprocessor-based systems can run at a very high speed because of the technology involved. Microcontroller based systems run up to 200MHz or more depending on the architecture.
It’s used for general purpose applications that allow you to handle loads of data. It’s used for application-specific systems.
It’s complex and expensive, with a large number of instructions to process. It’s simple and inexpensive with less number of instructions to process.

 

Q) What is ISR?

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. The Cortex-M processors family has the NVIC that manages the execution of the interrupt.

 

Q) What is interrupt latency?

It is an important question that is asked by the interviewer to test the understanding of Interrupt. Basically, interrupt latency is the number of clock cycles that are taken by the processor to respond to an interrupt request. This number of the clock cycle is count between the assertions of the interrupt request and the first instruction of the interrupt handler.

Interrupt Latency on the Cortex-M processor family

The Cortex-M processors have very low interrupt latency. In the below table, I have mentioned, Interrupt latency of Cortex-M processors with zero wait state memory systems.

Processors Cycles with zero wait state memory
Cortex-M0 16
Cortex-M0+ 15
Cortex-M3 12
Cortex-M4 12
Cortex-M7 12

 

Q) Explain the Architecture of the 8051 microcontrollers?

See this Article, Architecture of the 8051 microcontrollers.

 

Q) Explain the Pin Diagram of the 8051 microcontrollers?

See this Article, Pin Diagram of 8051 microcontrollers.

 

Q) What is a nested interrupt?

In a nested interrupt system, an interrupt is allowed to any time and anywhere even an ISR is being executed. But, only the highest priority ISR will be executed immediately. The second highest priority ISR will be executed after the highest one is completed.

The rules of a nested interrupt system are:

  • All interrupts must be prioritized.
  • After initialization, any interrupts are allowed to occur anytime and anywhere.
  • If a low-priority ISR is interrupted by a high-priority interrupt, the high-priority ISR is executed.
  • If a high-priority ISR is interrupted by a low-priority interrupt, the high-priority ISR continues executing.
  • The same priority ISRs must be executed by time order.

 

If you want to learn STM32 from scratch, you should follow this course “Mastering Microcontroller with Embedded Driver Development“. The course contains video lectures of 18.5-hours length covering all topics like, Microcontroller & Peripheral Driver Development for STM32 GPIO, I2C, SPI, USART using Embedded C.

embedded C interview questions

Enroll In Course

 

Q) What is NVIC in ARM Cortex?

The Nested Vector Interrupt Controller (NVIC) in the Cortex-M processor family is an example of an interrupt controller with extremely flexible interrupt priority management. It enables programmable priority levels, automatic nested interrupt support, along with support for multiple interrupt masking, whilst still being very easy to use by the programmer.

The Cortex-M3 and Cortex-M4 processors the NVIC supports up to 240 interrupt inputs, with 8 up to 256 programmable priority levels

embedded C interview questions

 

 

Q) Can we change the interrupt priority level of the Cortex-M processor family?

Yes, we can.

 

Q) 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.

  • Declaration of the Stack area.
  • Declaration of the Heap area.
  • Vector table.
  • Reset handler code.
  • Other exception handler code.

 

Q) What are the start-up code steps?

Start-up code for C programs usually consists of the following actions, performed in the order described:

  • Disable all interrupts.
  • Copy any initialized data from ROM to RAM.
  • Zero the uninitialized data area.
  • Allocate space for and initialize the stack.
  • Initialize the processor’s stack pointer.
  • Create and initialize the heap.
  • Enable interrupts.
  • Call the main.

 

Q) What is the boot-loader?

In general, a bootloader is a code that executes at the instant the CPU comes out of reset until it passes off control of the system to the OS. It performs basic initialization of the CPU and sometimes some other peripheral devices, such as disk subsystems, sometimes network controllers, perhaps timers, DMA controller, video controller, UART(s), etc. Sometimes it can have an interactive component, or it might be completely invisible.

In Non-OS MCU you can create your own bootloader (basically an application) to check the integrity of the image and with some require initialization. You can also upgrade the image using the help of a bootloader application.

 

Q) What is DMA in an embedded system?

Direct memory access (DMA) is a feature of computer systems that allows certain hardware subsystems to access main system memory (random-access memory) independent of the central processing unit (CPU).

 

Q) What is the difference between the I2c and SPI communication Protocols?

See this Article,  I2C vs SPI

 

Q) What is the difference between Asynchronous and Synchronous Communication?

There are the following differences between asynchronous and synchronous communication.

Asynchronous Communication Synchronous Communication
There is no common clock signal between the sender and receivers. Communication is done by a shared clock.
Sends 1 byte or character at a time. Sends data in the form of blocks or frames.
Slow as compare to synchronous communication. Fast as compare to asynchronous communication.
Overhead due to start and stop bit. Less overhead.
Ability to communicate long distance. Less as compared to asynchronous communication.
A start and stop bit used for data synchronization. A shared clock is used for data synchronization.
Economical Costly
RS232, RS485 I2C, SPI.

 

Q) What is the difference between Bit Rate and Baud Rate?

Bit Rate Baud Rate
Bit rate is the number of bits per second. Baud rate is the number of signal units per second.
It determines the number of bits traveled per second. It determines how many times the state of a signal is changing.
Cannot determine the bandwidth. It can determine how much bandwidth is required to send the signal.
This term generally used to describe the processor efficiency. This term generally used to describe the data transmission over the channel.
Bit rate = baud rate x the number of bits per signal unit. Baud rate = bit rate / the number of bits per signal unit.

 

Q) How to implement EEPROM with 8051 using bit-banging?

See this article, EEPROM interfacing with 8051 microcontrollers.

 

Q) How to interface relay with 8051 microcontrollers?

See this article, Interfacing of a relay with 8051.

Q) What do you mean by a real-time system?

A real-time system is a time-bound system that has well defined fixed time constraints. Processing must be done within the defined constraints or the system will fail.

 

Q) What is RTOS?

RTOS stands for Real-Time Operating System. It specially designed to run the application with very precise timing and a high degree of reliability. An RTOS system must have response time predictability and it must be deterministic.

 

Q) What is the kernel?

The kernel is a computer program that is the core of a computer’s operating system, with complete control over everything in the system. On most systems, it is one of the first programs loaded on start-up (after the bootloader). It handles the rest of the start-up as well as input/output requests from software, translating them into data-processing instructions for the central processing unit. It handles memory and peripherals like keyboards, monitors, printers, and speakers.

 

Q) What are the differences between process and thread?

Threads differ from traditional multitasking operating-system processes in several ways:

  • The processes are typically independent, while threads exist as subsets of a process.
  • The processes carry considerably more state information than threads, whereas multiple threads within a process share process state as well as memory and other resources.
  • The processes have separate address spaces, whereas threads share their address space.
  • The processes interact only through system-provided inter-process communication mechanisms.
  • Context switching between threads in the same process typically occurs faster than context switching between processes.

 

Q) Can MCU run code directly from flash?

Yes, Most of the MCU executes code directly from the flash.

 

Q) List various timers in embedded systems?

Every MCU has a different list of timers. Here I am mentioning a few types of timers. If you know another one then please write a comment in the comment box I will add in this list.

  • Watchdog Timer (WDT)
  • General Purpose of Timer
  • Interval Timer (Programmable timer)
  • Systick Timer
  • Real-Time Clock (RTC)

 

Q) What is the difference between Memory-mapped I/O and Isolated I/O?

ISOLATED I/O

MEMORY MAPPED I/O

Different address spaces for memory and I/O devices Same address bus to address memory and I/O devices
All address can be used by the memory because have different address space for memory and I/O device. Address space shared with I/O devices so addressable memory become less for memory.
Uses a special class of CPU

instructions to access I/O devices.

Access to the I/O devices using regular instructions
In this I/O address are called ports. Normal memory address are for both
More efficient due to separate buses Lesser efficient
Larger in size due to more buses Smaller in size
It is complex due to separate logic is used to control both. Simpler logic is used as I/O is also treated as memory only.
x86 Intel microprocessors – IN and OUT instructions It is most widely used I/O method

 

Q) What is the difference between mutex and semaphore?

The most important difference between semaphore and mutex is that mutex can be released only by the thread that had acquired it, but semaphore can be signaled by any thread (or process).

 

Q) What is the SPI communication protocol?

The serial peripheral interface is four wire-based full-duplex communication protocol these wire generally known as MOSI (master out slave in), MISO (master in slave out), SCL (a serial clock which produces by the master) and SS (slave select line which use to select specific slave during the communication).

SPI follows the master and slave architecture and communication is always started by the master. SPI is a synchronous communication protocol because the clock is shared by the master and slave.

SPI is supported only multi-slave does not support multi-master and slaves are selected by the slave select signal. In SPI during the communication data is shifted out from the master and shifted into the slave vice- versa through the shift register.

 

Q) How many wires are required for SPI communication?

The serial peripheral interface is four wire-based protocol these wire generally known as MOSI (master out slave in), MISO (master in slave out), SCL (serial clock which produces by the master) and SS (slave select line which use to select specific slave during the communication).

SPI com

 

Q) What are the advantages of the SPI communication protocol?

  • There is no start and stop bits, so the data can be streamed continuously without interruption.
  • It supports full-duplex.
  • No need for precision oscillators in slave devices as it uses a master’s clock.
  • No complicated slave addressing system like I2C.
  • Higher data transfer rate than I2C (almost twice as fast).
  • Separate MISO and MOSI lines, so data can be sent and received at the same time.
  • Simple software implementation.

 

Q) What are the disadvantages of the SPI communication protocol?

  • If there is more than one slave in communication then the wiring will be complex.
  • Uses four wires (I2C and UARTs use two).
  • No acknowledgment that the data has been successfully received (I2C has this).
  • No form of error checking like the parity bit in UART.
  • It only allows for a single master.

 

Q) Can devices be added and removed while the system is running in I2C?

Yes because Hot swapping is possible in I2C protocol.

 

Q) Difference between RS232 and RS485 (RS232 vs RS485)?

See this Article, RS232 vs RS485.

 

Q) What is I2C communication?

I2C is a serial communication protocol. It provides good support to the slow devices, for example, EEPROM, ADC, I2C LCD, and RTC, etc. It is not only used with the single board but also used with the other external components which have connected with boards through the cables.

I2C is basically a two-wire communication protocol. It uses only two-wire for communication. In which one wire is used for the data (SDA) and other wire is used for the clock (SCL).

In I2C, both buses are bidirectional, which means the master able to send and receive the data from the slave. The clock bus is controlled by the master but in some situations slave is also able to suppress the clock signal, but we will discuss it later.

Additionally, an I2C bus is used in the various control architecture, for example, SMBus (System Management Bus), PMBus (Power Management Bus), IPMI (Intelligent Platform Management Interface), etc.

 

Q) What does I2C stand for?

Inter-Integrated Circuit

 

Q) Can we monitor the serial communication like SPI/I2C/RS232?

Yes, we can. There are many analyzers available, you can check this analyzer “Siglent SDS1104X-E “.

 

Q) How many wires are required for I2C communication?

In I2C only two buses are required for the communication, the serial data bus (SDA) and serial clock bus (SCL).

 

Q) I2C is Synchronous or Asynchronous Communication?

I2C is Synchronous Communication.

 

Q) What are commonly found errors in embedded systems?

Here I am mentioning a few common errors which occur while we writing firmware for an embedded device or making an embedded system.

  • Accessing invalid memory location, like a wild pointer, dangling pointer, or accessing array beyond the boundary. In short, you can say accessing invalid or illegal memory.
  • Generally, we avoid dynamic memory allocation in MCU based projects but if you are using the memory management function like malloc or calloc then you must be careful and should avoid illegal memory allocation like malloc(0). Sometimes it creates hidden issues and can because of memory leak.
  • Wrong addressing of address lines and data lines within a circuit.
  • Segmentation fault and Stackoverflow.
  • If your application is multitasking then you should use the synchronization technique very carefully. It can create a problem.
  • Wrong insertion of Memory devices into memory slots.
  • Transient current and static charges which damages memory devices.
  • Sometimes control signals are faulty.

 

Q) Is it possible to have multiple masters in I2C?

Yes I2C support multiple master and multiple slaves.

 

Q) What is CAN?

A Controller Area Network (CAN bus) is a robust vehicle bus standard designed to allow microcontrollers and devices to communicate with each other in applications without a host computer. It is a message-based protocol, designed originally for multiplex electrical wiring within automobiles to save on copper, but can also be used in many other contexts.

can protocol interview questions and answers

 

Q) What is Featured of CAN Protocol?

There are few features of can protocol.

  • Simple and flexible in Configuration.
  • CAN is Message-Based Protocol.
  • Message prioritization feature through identifier selection.
  • CAN offer Multi-master Communication.
  • Error Detection and Fault Confinement feature.
  • Retransmission of the corrupted message automatically when the bus is idle.

Q) Why Can Is Having 120 Ohms At Each End?

To minimize the reflection reference, to reduce noise. To ensure that reflection does not cause communication failure, the transmission line must be terminated.

Q) Why CAN Bus uses differential Cable?

CAN Protocol used two-wire twisted-pair cables for CAN-Bus architecture to reduce cross-talk and EMI.

 

Q) What is voltage Levels in CAN Protocol?

Bus level according to ISO 11898.

  • CANH voltage level is 3.3 Volt
  • CANL Voltage Level is 1.5 Volt

voltage level in CAN

 

 

Q) In I2C, SPI, and CAN which one is best?

You can not say which one is the best. Each protocol has its own benefits and limitation. We select the communication protocol as per the project requirement.

 

Q) How to interface Led with PIC microcontroller.

See this article, How to interface Led with PIC Microcontroller?

 

Q) How to write data in the internal EEPROM of PIC microcontroller?

See this article, How to write data in internal EEPROM in PIC.

 

Q) How to create a custom character on LCD?

See this article, How to create a custom character on LCD?

 

Q) Difference between UART and USART(UART vs USART)?

See this Article,  UART vs USART.

 

Q) How to interface keyboard with PIC microcontroller?

See this article, How to interface keyboard with PIC?

 

I believe that the above mentioned embedded system interview questions are helpful. Here, I have mentioned some unsolved embedded system interview questions for you.

  • What is the difference between flash memory, EPROM, and EEPROM?
  • What is the difference between Volatile & Non Volatile Memory?
  • What is DMA?
  • What is a watchdog timer?
  • What is semaphore?
  • What is the spinlock?
  • Writing portable code in C.
  • How do you make an inline assembly code in C?
  • Explain how shared memory works? (A good candidate will know details like why pointers are stored as offsets and how to protect memory regions using semaphores. )
  • What happens on a system call? (A good answer will include a description of processor interrupts and how the hardware handles them, scheduling decisions, marshaling parameters, etc. (For embedded programmers a question dealing with concurrent operations can be substituted.).
  • How would you read in a string of unknown length without risking buffer overflow?
  • Questions from your project. How did you connect that particular sensor to the board? Any protocol? The clock frequency of the used controller? pinouts of the sensors?
  • Why did you choose that controller for your project and why not the other one?
  • How will you debug a program?
  • What to do if your software in the MCU hangs?
  • What is the use of JTAG?
  • How do you use Oscilloscope, Logic Analyzer, Spectrum Analyzer, CAN analyzer?
  • Difference between a BIOS and UEFI boot process?
  • Difference between a PC Boot and Smartphone boot?
  • What are an active error, passive error, and Bus-off state?
  • What is bit time? Calculate no. of time quanta required to achieve 500kbps bit rate if system frequency is 40mhz and clock divider is 4?
  • What is the difference between the C and embedded C?

 

Recommended Post:

 

You can see this link for more detail about ISR.