Embedded C Interview Questions
Embedded C Interview Questions
Basic Level
- What is Embedded C?
microcontrollers.
Embedded C interacts directly with hardware using registers and bit-level operations.
Microcontrollers are single-chip devices with CPU, RAM, ROM, and I/O. Microprocessors only
It tells the compiler not to optimize a variable because it can be changed by hardware or ISR.
Prevents accidental changes to values that should remain constant (e.g., config data or ROM
values).
Technique where I/O devices are mapped into the address space and accessed like normal
memory.
Polling checks device status in a loop. Interrupt-driven allows CPU to perform tasks and react to
events.
Using compiler-specific syntax (e.g., `void __interrupt() ISR(void)` or with vector table setup).
Used for setting, clearing, and toggling specific bits in registers or variables.
Use smaller data types, avoid dynamic allocation, and optimize logic/loops.
Removing noise from mechanical button presses using delay or software filtering.
Blocking waits for operation to complete; non-blocking continues execution while waiting.
Advanced Level
- What are critical sections and how do you protect them?
Code that must not be interrupted. Protected using disable/enable interrupts or mutex in RTOS.
Define memory layout, segment locations (e.g., Flash, RAM) for program sections.
Occurs when stack exceeds its limit. Prevent using large global variables and monitoring usage.
management.
Higher priority interrupts can pre-empt current ISR. Managed by priority levels and stack use.
Startup code initializes memory and sets up vector table before main() runs.
Configure DMA controller to transfer data between peripherals and memory without CPU
intervention.
Practical Questions
- Write a program to blink an LED using a delay loop.
ISR(INT0_vect) { flag = 1; }