0% found this document useful (0 votes)
35 views9 pages

Embedded C in 5 Segment and

EMBEDDED C IN 5 SEGMENT ANDEMBEDDED C IN 5 SEGMENT ANDEMBEDDED C IN 5 SEGMENT ANDEMBEDDED C IN 5 SEGMENT AND

Uploaded by

Siddharth Doshi
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)
35 views9 pages

Embedded C in 5 Segment and

EMBEDDED C IN 5 SEGMENT ANDEMBEDDED C IN 5 SEGMENT ANDEMBEDDED C IN 5 SEGMENT ANDEMBEDDED C IN 5 SEGMENT AND

Uploaded by

Siddharth Doshi
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/ 9

EMBEDDED C IN 5 SEGMENT AND EACH

CONTAINS 50 QUESTIONS
Here are comprehensive Embedded C interview/exercise questions organized into 5 major
segments, each with 50 questions, arranged from basic to advanced/detailed level in table
format:

1. Data Types, Variables, Operators & Control Flow (50 Questions)


# Question

1 What is Embedded C? How does it differ from standard C?

2 List the basic data types used in Embedded C.

3 What is the size of int, char, float, and double in most microcontrollers?

4 Explain signed vs unsigned data types.

5 Why is volatile used in Embedded C? Give examples.

6 What is static storage class? Where is it used in embedded development?

7 How do you declare and initialize variables in Embedded C?

8 What is the use of bit-fields? Give a code example.

9 How do you choose variable types to minimize memory usage?

10 Explain scope and lifetime of variables in Embedded C.

11 What are arithmetic, relational, and logical operators?

12 Describe bitwise operators and give practical embedded examples.

13 Explain the use of &&, ||, and ! operators.

14 How does the ternary operator work? Example in GPIO control.

15 What is the difference between ++i and i++ in C?

16 Write a simple if-else code for LED ON/OFF depending on a sensor input.

17 How to use switch-case for key detection in embedded keypads?

18 How do loops (for, while, do-while) help in embedded programming?

19 Explain break and continue statements and their limitations.

20 When should you use infinite loops in embedded systems?


# Question

21 How to exit from a loop if a timer interrupt occurs?

22 Explain nested loops and give an example from embedded application.

23 Write a code to count pulses from a GPIO pin using a loop.

24 Discuss precautions when using loops in time-critical embedded functions.

25 What are structured data types in C (struct, enum, union)? Where are they used?

26 How do you use enums for state machines?

27 Explain typedef and its usage in embedded code readability.

28 What is a union? Give a use case for communication protocols.

29 Write a C code to invert all bits of a variable using bitwise ops.

30 How to define constants using #define and const keyword?

31 Describe volatile's use in polling and interrupt-driven code.

32 What are local and global variables? How to avoid naming conflicts?

33 How to implement a simple delay in C using a loop?

34 What is integer overflow? How to handle it?

35 Why are arrays better than individual variables in data logging?

36 Give an example of using switch-case for finite state machine.

37 Code for LED blinking using for loop.

38 Code for buzzer ON for 5 seconds using timer and loop.

39 When is recursive logic dangerous in embedded C?

40 How do you structure critical sections in Embedded C?

41 What precautions to take in arithmetic ops to avoid division by zero?

42 How to optimize code for speed and size at control-flow level?

43 What is memory alignment? How does it affect variable access?

44 How do coding standards (MISRA) affect variable usage?

45 Discuss importance of comments/documentation for variable logic.

46 Explain variable shadowing and how to avoid it.

47 How do you simulate switch debouncing in code logic?

48 How are watchdog timers handled in control-flow?

49 Why is it important to minimize the use of floating-point arithmetic?

50 Write a loop-based code for generating a square wave on a micro pin.


2. Pointers, Memory Management, Arrays & Structures (50 Questions)
# Question

1 What is a pointer? Give its syntax and simple example.

2 Discuss usage of pointers in accessing hardware registers.

3 Explain risks of using wild/dangling pointers in embedded systems.

4 What is NULL pointer? When is it needed?

5 Explain constant pointer and pointer to constant with example.

6 How are pointers used in passing data to ISRs?

7 What are void pointers, where are they used in drivers?

8 How is pointer arithmetic used for iterating buffers?

9 Discuss memory fragmentation in embedded C and ways to avoid it.

10 How to allocate dynamic memory in embedded systems?

11 Why is dynamic memory allocation avoided in critical embedded code?

12 How do you free dynamically allocated memory?

13 Explain stack vs heap memory in embedded C.

14 How to avoid buffer overflows?

15 What is an array? How is it declared and used?

16 How to initialize arrays efficiently?

17 How to access multidimensional arrays in Embedded C?

18 Describe passing arrays to functions using pointers.

19 How to use arrays for sensor data acquisition?

20 What is a structure in C? Example: storing sensor values.

21 How to use struct pointers for linked lists?

22 Structure padding and its impact on memory usage.

23 How can unions and structs interact in communication protocols?

24 Example: union for overlaying a byte array over an int.

25 How to use pointers in data packet manipulation?

26 How are callback functions implemented using pointers?

27 Give code for swapping two variables using pointers.

28 What care is required when sharing pointers between threads/ISRs?

29 How to clear buffers and arrays efficiently?

30 Give example code for a circular buffer using arrays and pointers.
# Question

31 How to search for an element in an array (linear/binary search)?

32 Implement a queue using arrays and pointers.

33 What are bitwise operations for array packing/unpacking?

34 How to reverse an array in-place using pointers?

35 Code example for passing struct to a function by reference.

36 How to implement a stack (LIFO) using array?

37 Memory map of a structure — how to view it?

38 Discuss usage of pointers in RTOS message queues.

39 Example of structure array for sensor groups.

40 How to access peripheral registers using pointer structures?

41 Explain strict aliasing and its impact on embedded performance.

42 How do you simulate union for protocol overlays?

43 How can DMA use memory pointers for data transfer?

44 What is the use of const in pointer declarations?

45 Explain the use of memory-mapped IO data structures.

46 Discuss alignment requirements for DMA and structures.

47 How do you safeguard pointer access in critical sections?

48 What debugging aids exist for pointer-related bugs?

49 How would you represent a fixed-point number using a struct?

50 Example code for linked-list node insert and delete operations.

3. Peripheral Access, Interrupts, Timers & Low-Level Communication (50


Questions)
# Question

1 What are peripheral registers, and how are they accessed in Embedded C?

2 How to configure GPIO pins for input and output?

3 What is direct register access? Give code example.

4 Describe the difference between polling and interrupt methods.

5 How to configure and handle external interrupts?

6 Write code for edge-triggered interrupt configuration.

7 How to clear an interrupt flag in a microcontroller?


# Question

8 What is an ISR (Interrupt Service Routine)? How is it declared in C?

9 How do you pass data from ISR to main loop safely?

10 What precautions are needed when accessing shared data in ISRs?

11 How to implement debouncing for a button interrupt?

12 What is timer overflow and how is it managed in Embedded C?

13 Configure a timer in C to generate a periodic interrupt.

14 How to implement time delays using hardware timers?

15 Explain PWM generation using timers.

16 How to read ADC value via registers in Embedded C?

17 What is SPI communication and how is it implemented?

18 How to initialize I2C communication in Embedded C?

19 Write code to send and receive bytes over UART.

20 Implement circular buffer for UART receive.

21 Write an ISR for UART receive interrupt.

22 How to handle buffer overflows in low-level communication?

23 Implement CRC calculation for data integrity.

24 Code for SPI master sending data to slave.

25 Example: configuring I2C master/slave address in C.

26 How to implement callback mechanism for communication events?

27 How to use DMA for peripheral data transfers?

28 Discuss low-layer hardware abstraction in Embedded C.

29 What is atomic access? How is it ensured for peripherals?

30 How to measure time between two events using timers?

31 Write code for interrupt-driven ADC sampling.

32 What are watchdog timers? How to configure/reset them?

33 How to handle SPI errors in communication?

34 Example code for synchronous vs asynchronous UART transmission.

35 How to enable/disable interrupts globally?

36 How to interface sensors using I2C and C?

37 How to optimize GPIO access speed?

38 Using sleep modes in C to save power during idle.

39 Write code to detect timer timeout and execute specific function.


# Question

40 How are hardware semaphores used in multi-core MCUs?

41 Example of using low-level bit manipulation for setting/clearing flags.

42 How to synchronize communication between MCU and peripheral?

43 Handling collision or bus errors in I2C/SPI.

44 How to implement event-driven programming at register level?

45 How do you test and validate peripheral drivers?

46 What precautions are needed for shared interrupts in MCUs?

47 Code for configuring multiple timers for different tasks.

48 How do you access internal temperature sensor using C code?

49 How to do power management via disabling unused peripherals?

50 What is double-buffering in communication and how to implement it?

4. Embedded C - Code Optimization, Toolchains, Portability, MISRA & Standards


(50 Questions)
# Question

1 What is code optimization, and why is it important in embedded systems?

2 Give examples of common compiler optimizations for Embedded C.

3 How to minimize code size for resource-constrained MCUs?

4 Discuss function inlining and its benefits/drawbacks.

5 How does loop unrolling help performance in embedded code?

6 Write an example of using volatile with optimization settings.

7 What is tail-call optimization? How does it affect embedded functions?

8 Explain dead code elimination.

9 How to avoid stack overflow in optimized embedded code?

10 Discuss inline vs static functions.

11 What is a cross-compiler? Why is it needed?

12 Explain the typical embedded C build process.

13 What is a linker script, and why is it critical?

14 How do you achieve code portability across microcontroller families?

15 What are hardware abstraction layers (HAL)?

16 Why are coding standards like MISRA C mandatory in safety projects?


# Question

17 Discuss typical MISRA rules and their consequences.

18 Identify common non-compliant code per MISRA C.

19 Explain portability issues with unions and pointer math.

20 What are the advantages of using ANSI C in embedded projects?

21 How do you document embedded code for maintainability?

22 What tools are used for static analysis of Embedded C?

23 How is code coverage measured for embedded applications?

24 What is the use of assert macros in embedded code?

25 How do you handle endianess in portable code?

26 Give an example of using preprocessor macros for platform-specific code.

27 Discuss using weak symbols for default handlers.

28 How do toolchains support debugging and simulation?

29 What is profiler and how is it used to optimize embedded code?

30 Explain Link-Time Optimization (LTO).

31 What are the best practices for stack and heap usage in Embedded C?

32 Discuss role of RTOS-aware tools and hooks in Embedded C.

33 What are compliance challenges with certifying embedded software?

34 How to use assertions for parameter range checking in functions?

35 What accepted idioms exist for error handling and reporting?

36 What is code branching and its optimization significance?

37 Explain function pointer arrays for efficient event handling.

38 How do you test for and prevent integer overflows?

39 Discuss using CRC or hash for code/data integrity verification.

40 How would you implement device drivers in a portable way?

41 How should you design for backward compatibility?

42 What are lock/unlock mechanisms in embedded code?

43 How to handle deprecated hardware features in codebase?

44 Discuss modular code structuring strategies.

45 What are the implications of the volatile keyword on compiler optimization?

46 How do you use conditional compilation for hardware variants?

47 Example of code for RAM vs Flash code execution optimization.

48 What is the role of const correctness in embedded C?


# Question

49 Discuss safe interfaces for hardware interaction.

50 How do you mitigate real-time constraints through code design?

5. Real Time Concepts, RTOS Integration & Debugging in Embedded C (50


Questions)
# Question

1 What is real-time in the context of embedded systems?

2 How does Embedded C support real-time programming?

3 Discuss priority inversion and its handling.

4 How do you measure latency in real-time applications?

5 How to integrate your C application with an RTOS?

6 Write simple task code compatible with an RTOS in C.

7 Example of inter-task communication using queues in C.

8 How is timing accuracy ensured in Embedded C?

9 Discuss event-driven programming in embedded systems.

10 What is tick timer? How is it used in real-time code?

11 Code to synchronize two tasks using mutex in C.

12 How do semaphores work in RTOS-aware C code?

13 Steps for debugging task synchronization issues.

14 How to measure and optimize context-switch time?

15 Describe message passing between tasks and ISRs.

16 What is the use of watchdog timer in RTOS context?

17 How to monitor and debug task stack usage?

18 What are typical debugging interfaces supported by MCUs?

19 How to use breakpoints and watchpoints in embedded debuggers?

20 What are the limitations of debugging optimized code?

21 How to capture and analyze system traces/logs?

22 What is post-mortem debugging and how is it performed?

23 Example of priority assignment to tasks.

24 How to implement timer-driven events in Embedded C RTOS app?

25 Steps to handle ISR latencies in C code.


# Question

26 How is memory management tracked in multi-tasked embedded apps?

27 What are the uses of assertion in RTOS code?

28 How to synchronize access to peripherals in multiple tasks?

29 How to avoid starvation and deadlock in scheduling?

30 Describe round-robin scheduling in Embedded C RTOS.

31 How is code validated for race conditions?

32 Steps to profile timing of periodic and aperiodic tasks.

33 Code for implementing a periodic software timer.

34 Describe debugging techniques for stack overflow.

35 How to implement dynamic priority change in RTOS application?

36 How to detect and recover from task crashes?

37 What are common pitfalls in multitasking C code?

38 Steps for integrating third party IP in RTOS project.

39 How can RTOS hooks help with debugging and profiling?

40 How are external interrupts integrated with RTOS tasks?

41 What are effective strategies for power management in RTOS apps?

42 Code for event-driven callback handling.

43 How does priority inheritance prevent blocking issues?

44 Discuss static vs dynamic allocation of RTOS tasks.

45 What is thread-safe coding practice in Embedded C?

46 Write code for logging error events and system status.

47 How does RTOS-aware debugging differ from bare-metal debugging?

48 Discuss runtime validation tools for embedded systems.

49 How do you handle user input in real-time Embedded C systems?

50 What are future trends in real-time Embedded C and debugging tools?

Let me know if you want sample answers, code snippets, or explanations for any set!

You might also like