Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

What is the difference between C and embedded C?

The C standard doesn’t care about embedded, but vendors of embedded


systems usually provide standalone implementations with whatever amount of
libraries they’re willing to provide.

C is a widely-used general-purpose high-level programming language mainly


intended for system programming. On the other side, Embedded C is an
extension to the C programming language that provides support for
developing efficient programs for embedded devices. It is not a part of the C
language

C language Embedded C

C is a general-purpose Embedded C is nothing but an extension C


programming language used to programming language, and it is used to
design any desktop-based develop micro-controller based applications.
applications.

C is a type of high-level Embedded C is an extension of the C


programming language. programming language.

C programming language is the Embedded C is a completely hardware-


hardware-independent language. dependent language.

The compilers of the C The compilers of Embedded C are OS


programming language are OS- independent.
dependent.

In the C programming language, the In Embedded C language, a specific compiler


standard compilers are used to that can generate particular hardware/micro-
compile and execute the program. controller based output is used to compile the
code.

Some popular compilers used to Some popular compilers used to execute an


execute a C language program are: Embedded C language program are:
GCC (GNU Compiler collection) Keil compiler
Borland Turbo C BiPOM ELECTRONIC
Intel C++ Green Hill software
C programming language has a free In Embedded C language, formatting depends
format of program coding. upon the type of microprocessor and Controllers
used in the application.

C language also supports other Embedded C language supports only the


various programming languages required processor of the application and not
during application. the programming languages.

In the C programming language, we In Embedded C language, we can give only the


can give input to the program while pre-defined inputs to the running program.
it is running.

The C programming language Embedded C supports the high level of


supports normal optimization. optimization.

C programming language generally Embedded C language has to use with the


uses the resources of a desktop PC limited resources, such as RAM, ROM, I/Os on an
like memory, OS, etc. embedded processor.

Some examples of the C Program Some examples of the Embedded C Program


applications: applications:
Logical programs DVD
System software programs etc. TV
Digital camera etc.

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.

NVIC: Nested Vectored Interrupt Control 

Q) Can we pass any parameter and return a value from the


ISR?
An ISR returns nothing and not allow to pass any parameter. An ISR is called
when a hardware or software event occurs, it is not called by the code, so
that’s the reason no parameters are passed into an ISR.

Q) How do you measure interrupt latency?


With the help of the oscilloscope, we can measure the interrupt latency. You
need to take the following steps.

 First takes two GPIOs.


 Configure one GPIO to generate the interrupt and second for the
toggling (if you want you can attach an LED).
 Monitor the PIN (using the oscilloscope or analyzer) which you have
configured to generate the interrupt.
 Also, monitor (using the oscilloscope or analyzer) the second pin which
is toggled at the beginning of the interrupt service routine.
 When you will generate the interrupt then the signal of both GPIOs will
change.

The interval between the two signals (interrupt latency) may be easily read
from the instrument.

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
Q) Why “C” language mostly preferred than assembly
language?
C helps programmers focus on the structure of the code rather than the low-
level demands of the CPU. They can organize code into components, such as
functions and files and they have ways of managing the complexity of a
project; without thinking about the nitty-gritty of issues such as how function
calls work.

Since C is a portable language, code can be organized into general-purpose


libraries that can be used on any platform, often with no modification. It is a
great weapon against ‘reinventing the wheel.

Q) What is the start-up code?


A start-up code is called before 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 main.

Q) What is the stack overflow?


If your program tries to access beyond the limit of the available stack memory
then stack overflow occurs. In other words, you can say that a stack overflow
occurs if the call stack pointer exceeds the stack boundary.

If stack overflow occurs, the program can crash or you can say that
segmentation fault that is the result of the stack overflow.

Q) What is the cause of the stack overflow?


In the embedded application we have a little amount of stack memory as
compare to the desktop application. So we have to work on embedded
application very carefully either we can face the stack overflow issues that can
be a cause of the application crash.

Here, I have mentioned some causes of unwanted use of the stack.

 Improper use of the recursive function.


 Passing to many arguments in the function.
 Passing a structure directly into a function.
 Nested function calls.
 Creating a huge size local array.

 
Q) What is the difference between the I2c and SPI
communication Protocols?
In the embedded system, I2C and SPI both play an important role. Both
communication protocols are the example of synchronous communication but
still, both have some important differences.

The important difference between the I2C and SPI communication


protocol.

 I2C supports half-duplex while SPI is full-duplex communication.


 I2C requires only two-wire for communication while SPI requires three
or four-wire for communication (depends on requirement).
 I2C is slower as compared to the SPI communication.
 I2C draws more power than SPI.
 I2C is less susceptible to noise than SPI.
 I2C is cheaper to implement than the SPI communication protocol.
 I2C work on wire and logic and it has a pull-up resistor while there is no
requirement of a pull-up resistor in case of the SPI.
 In I2C communication we get the acknowledgment bit after each byte, it
is not supported by the SPI communication protocol.
 I2C ensures that data sent is received by the slave device while SPI
does not verify that data is received correctly.
 I2C supports multi-master communication while multi-master
communication is not supported by the SPI.
 One great difference between I2C and SPI is that I2C supports multiple
devices on the same bus without any additional select lines (work based
on device address) while SPI requires additional signal (slave select
lines) lines to manage multiple devices on the same bus.
 I2C supports arbitration while SPI does not support the arbitration.
 I2C support the clock stretching while SPI does not support the clock
stretching.
 I2C can be locked up by one device that fails to release the
communication bus.
 I2C has some extra overhead due to start and stop bits.
 I2C is better for long-distance while SPI is better for the short distance.
 In the last I2C developed by NXP while SPI by Motorola.

Q) What is the difference between Asynchronous and


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

7) Mention what is the difference between microprocessor and


microcontroller?
Microprocessor is managers of the resources (I/O, memory) which lie
outside of its architecture

Microcontroller have I/O, memory, etc. built into it and specifically designed
for control

8) What does DMA address will deal with?

DMA address deals with physical addresses. It is a device which directly


drives the data and address bus during data transfer. So, it is purely
physical address.

9) Explain what is interrupt latency? How can you reduce it?

Interrupt latency is a time taken to return from the interrupt service routine
post handling a specific interrupt. 

By writing minor ISR routines, interrupt latency can be reduced.

10) Mention what are buses used for communication in embedded


system?

For embedded system, the buses used for communication includes

 I2C: It is used for communication between multiple ICs


 CAN: It is used in automobiles with centrally controlled network
 USB: It is used for communication between CPU and devices like
mouse, etc.

11) List out various uses of timers in embedded system?

Timers in embedded system are used in multiple ways

 Real Time Clock (RTC) for the system


 Initiating an event after a preset time delay
 Initiating an even after a comparison of preset times
 Capturing the count value in timer on an event
 Between two events finding the time interval
 Time slicing for various tasks
 Time division multiplexing
 Scheduling of various tasks in RTOS

12) Explain what is a Watchdog Timer?

A watchdog timer is an electronic device or electronic card that executes


specific operation after certain time period if something goes wrong with an
electronic system.

13) Explain what is the need for an infinite loop in embedded


systems?
Embedded systems require infinite loops for repeatedly processing or
monitoring the state of the program.  For instance, the case of a program
state continuously being verified for any exceptional errors that might just
happen during run-time such as memory outage or divide by zero, etc.

Q) What are the limitations of I2C interface?

 Half-duplex communication, so data is transmitted only in one direction


(because of the single data bus) at a time.
 Since the bus is shared by many devices, debugging an I2C bus
(detecting which device is misbehaving) for issues is pretty difficult.
 The I2C bus is shared by multiple slave devices if anyone of these
slaves misbehaves (pull either SCL or SDA low for an indefinite time)
the bus will be stalled. No further communication will take place.
 I2C uses resistive pull-up for its bus. Limiting the bus speed.
 Bus speed is directly dependent on the bus capacitance, meaning
longer I2C bus traces will limit the bus speed.

Q) Significance of watchdog timer in Embedded Systems?


Using the watchdog timer you can reset your device. It is a useful tool in
helping your system recover from transient failures.

20) What do you understand by a function pointer?


A function pointer is a pointer that points to a function instead of a variable. That's
why a function pointer is completely different from the class of other pointers. A
function pointer stores the address of a particular function so that the concerned
program can avail of it through function invoking.

What are inline functions?

Ans: The ARM compilers support inline functions with the keyword __inline.

These results in each call to an inline function being substituted by its body, instead
of a normal call.

This results in faster code, but it adversely affects code size, particularly if the inline
function is large and used often.

1. What is the difference between C and embedded C?


2. Is it faster to count down than it is to count up?
3. What is the difference between flash memory, EPROM, and EEPROM?
4. What is the difference between Volatile & Non Volatile Memory?
5. What are the differences between a union and a structure in C?
6. What is the difference between RS232 and UART?
7. Is it possible to declare struct and union one inside other? Explain with
example.
8. How to find the bug in code using the debugger if the pointer is pointing to
an illegal value.
9. What is DMA?
10. What is RTOS?
11. What are CAN and its uses?
12. Why is CAN having 120 ohms at each end?
13. Why is CAN message-oriented protocol?
14. What is the Arbitration in the CAN?
15. Standard CAN and Extended CAN difference?
16. What is the use of bit stuffing?
17. How many types of IPC mechanisms do you know?
18. What is a semaphore?
19. What is the spinlock?
20. What is the difference between c and embedded C?
21. Convert a given decimal number to a hex.
22. What is the difference between heap and stack memory?
23. How can a double-pointer be useful?
24. What is the difference between binary semaphore and mutex?
25. CAN frame-works?
26. How CAN will follow the Arbitration?
27. Explain CAN architecture with respect to OSI Layer?
28. What are the functions of CAN transceiver?
29. Why CAN Bus Topology uses terminator register at the end?
30. Explain High-Speed CAN and Low-Speed CAN?
31. Explain the types of CAN error? Which concept is used behind bit error
detection?
32. What are an active error, passive error, and Bus-off state?
33. 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?
34. How many Types of CAN frame exist? explain the functionality of each
frame?
35. What is CSMA/CA and CSMA/CD in CAN Communication?
36. Can Standard CAN and extended CAN coexist in the same network? who
will win arbitration if first arbitration field is the same?
37. What is the difference between the C and embedded C?
38. What is the sequential point in C?
39. Polling vs Interrupts
40.What is Prescaler in timers?
41.How to determine the accuracy of a ADC?
42.What is the interrupt vector table?
43.What is the PLL?
44.What are two of the hardware protocols used to communicate with SD
cards? Which will most likely work with more microcontrollers?
45.Describe each of the following? SRAM, Pseudo-SRAM, DRAM, ROM,
PROM, EPROM, EEPROM, MRAM, FRAM, flash memory.

In I2C, SPI and CAN which one is best?

Don’t give an answer to the interviewer that is best. As per industry requirement
and project need all three are best.

Every protocol has its unique quality to show performance in industry project.

46. .Why Timers?


Timer is not only used to generate delay but used to count pulses. Timers
maintain accuracy as per requirement. By using for loop we can generate delay
but will not get accuracy as per requirement. Timers maintain accuracy and
precise value. Timer calculation can be done by an external clock and controller
itself.

47. Why interrupts are prioritized?


48. 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.
49.
50. 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


51. 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

52.
 What Is Machine Cycle?
Answer :
The steps performed by computer processor for each machine language instruction
received. The machine cycle is 4 process cycle.
o Fetch: Retrieve an instruction from memory
o Decode: Translate the retrieved instruction into series of computer
commands.
o Execute: Execute the computer command.
o Store: Send and write the result back into memory.

You might also like