Embedded Interview Questions and Answers: 31 with Tested C Code (2026)
31 embedded systems interview questions for freshers, with compiled C code, protocol facts checked against the specs and Skill-Lync placement salary data.
Embedded interviews for freshers in India usually test four things: Embedded C (volatile, const, pointers, bit manipulation), microcontroller basics (interrupts, timers, ADC, PWM, startup code), serial protocols (UART, I2C, SPI, CAN) and RTOS concepts (task states, mutexes, priority inversion), the same skills the day-to-day job uses. Below are 31 questions with short, correct answers grouped the way interviewers move through them. Each answer gives the direct answer first, then the reason, then the follow-up you are likely to get next. Every C snippet is cut from a complete program that we compiled and ran, and the output shown is the real output.
In short
- 31 questions in 6 topics: Embedded C (11), microcontrollers (7), protocols (6), RTOS (4), debugging (1) and automotive (2).
- I2C runs at up to 100 kbit/s (Standard-mode), 400 kbit/s (Fast-mode), 1 Mbit/s (Fast-mode Plus) and 3.4 Mbit/s (High-speed mode) (NXP UM10204, Rev. 7.0, Oct 2021).
- Classical CAN carries 0 to 8 data bytes at up to 1 Mbit/s; CAN FD carries up to 64 bytes and can switch to a faster bit rate for the data phase (TI SLOA101B; CAN in Automation, read Nov 2026).
- Skill-Lync learners placed as Embedded Engineers had a median starting salary of ₹4.0 LPA (n = 138; Skill-Lync placement data, snapshot 15 Nov 2026).
- All 15 C programs compile with
cc -Wall -std=c11with no warnings (Apple clang 15, 64-bit Arm host). Sizes and byte order are for that host; we flag where a microcontroller differs.
About the salary figures: based on 3,711 Skill-Lync placement records up to 7 Nov 2026 (data snapshot of 15 Nov 2026). This is a starting point; we'll update it as new placements come in. The caveats are in the salary section below.
How do embedded interviews at Indian companies run?
For freshers, most service and automotive-software companies run three stages: an online test (aptitude plus C), one or two technical interviews, and an HR interview. Companies do not publish their round structure on their careers pages, so treat this as the commonly reported pattern rather than a rule.
Two prep-site write-ups dated May 2026 describe it this way. FACE Prep's Tata Elxsi guide lists a MeritTrac online test, a resume-based technical interview and an HR round, with Embedded Engineer questions on microcontrollers, volatile, ISRs, bit manipulation and UART/SPI/I2C/CAN. Its KPIT guide lists the same three rounds and, for ECE/EEE candidates, Embedded C, interrupts, serial protocols and basic AUTOSAR layering. That matches the topics below.
In Skill-Lync's own placement records, the companies that hired the most learners into embedded roles were Cyient (18 placements), Nexteer Automotive (17), Expleo Engineering (9), Tata Technologies (8), L&T Technology Services (7) and Ielektron (7) (snapshot 15 Nov 2026). More names are on our companies hiring embedded freshers page.
Embedded C interview questions
1. What does the volatile keyword do, and when must you use it?
volatile tells the compiler that a variable can change outside the code it can see, so every read and write in the source must really happen. Use it for memory-mapped hardware registers, variables shared between an ISR and the main loop, and variables shared between RTOS tasks.
Without it, an optimising compiler may read a flag once, keep it in a register and turn while (!flag) into an endless loop. On a PC, a signal handler plays the role of an ISR:
static volatile sig_atomic_t data_ready = 0; /* written by the "ISR" */
static void on_alarm(int sig) { (void)sig; data_ready = 1; }
int main(void) {
signal(SIGALRM, on_alarm);
alarm(1); /* "interrupt" fires in 1 s */
while (!data_ready) { } /* re-read on every pass */
printf("data_ready seen: loop exited\n");
return 0;
}
/* Output: data_ready seen: loop exited */
Follow-up: "Does volatile make a variable thread-safe or atomic?" No. It stops the compiler from caching the value, but a read-modify-write such as count++ can still be interrupted half-way. Protect it by briefly disabling interrupts, using an atomic type, or a mutex.
2. What is the difference between const int *p, int *const p and const volatile?
const int *p is a pointer to a constant int: you can move the pointer but not write through it. int *const p is a constant pointer: it always points to the same place, but you can change the value there. const int *const p locks both. Read the declaration right to left.
int a = 10, b = 20;
const int *p1 = &a; /* *p1 = 5; would not compile */
int *const p2 = &a; /* p2 = &b; would not compile */
const int *const p3 = &a;
p1 = &b; /* fine: pointer moves */
*p2 = 15; /* fine: a becomes 15 */
printf("*p1=%d *p2=%d *p3=%d\n", *p1, *p2, *p3);
/* Output: *p1=20 *p2=15 *p3=15 */
Follow-up: "Can a variable be both const and volatile?" Yes. A read-only status register is the textbook case: const volatile uint32_t *status. Your code may not write it (const), but the hardware changes it, so every read must go to the register (volatile).
3. What are the three uses of static in C?
A static local variable keeps its value between calls and is initialised once. A static global variable or function has internal linkage, so it is invisible to other .c files. (The third, rarer use is static inside an array parameter, such as int a[static 4], which promises at least 4 elements.)
static int next_id(void) {
static int id = 0; /* lives for the whole program */
return ++id;
}
int x = next_id();
int y = next_id();
int z = next_id();
printf("%d %d %d\n", x, y, z);
/* Output: 1 2 3 */
Follow-up: "Where is a static local stored?" Not on the stack. It goes in .data if it has a non-zero initial value, or .bss if it starts at zero (see question 17). In embedded code, making helpers static also keeps the global namespace clean and lets the compiler inline them.
4. Are arrays and pointers the same thing?
No. An array is a block of elements; a pointer is a variable that holds an address. An array name converts ("decays") to a pointer to its first element in most expressions, which is why a[2], *(a + 2) and even 2[a] all mean the same thing.
int a[5] = {10, 20, 30, 40, 50};
int *p = a;
printf("a[2]=%d *(a+2)=%d *(p+2)=%d 2[a]=%d\n", a[2], *(a+2), *(p+2), 2[a]);
printf("sizeof(a)=%zu sizeof(p)=%zu\n", sizeof(a), sizeof(p));
/* Output:
a[2]=30 *(a+2)=30 *(p+2)=30 2[a]=30
sizeof(a)=20 sizeof(p)=8 */
sizeof exposes the difference: 20 bytes for five 4-byte ints, but 8 bytes for a pointer on a 64-bit PC. On a 32-bit Cortex-M the pointer is 4 bytes. Both sizes are implementation-defined.
Follow-up: "Why does sizeof(arr) inside a function give the wrong count?" Because an array parameter, even written as int arr[], is really a pointer. Pass the length as a separate argument; the sizeof(a) / sizeof(a[0]) trick only works where the array itself is in scope.
5. How do you set, clear, toggle and test a bit?
Set with OR, clear with AND of the inverted mask, toggle with XOR, and test by shifting and masking with 1. Use unsigned masks (1u << n) so you never shift into the sign bit of a signed int.
#define BIT(n) (1u << (n))
#define SET_BIT(r, n) ((r) |= BIT(n))
#define CLEAR_BIT(r, n) ((r) &= ~BIT(n))
#define TOGGLE_BIT(r, n) ((r) ^= BIT(n))
#define TEST_BIT(r, n) (((r) >> (n)) & 1u)
uint8_t reg = 0x00;
SET_BIT(reg, 3); /* 0x08 */
TOGGLE_BIT(reg, 0); /* 0x09 */
CLEAR_BIT(reg, 3); /* 0x01 */
/* TEST_BIT(reg, 0) = 1, TEST_BIT(reg, 3) = 0 */
Follow-up: "Write the value 5 into bits 6 to 4 of a register without touching the other bits." Clear the field, then OR in the shifted value: ctrl = (ctrl & ~(0x7u << 4)) | (5u << 4);. Starting from 0x8F, the result is 0xDF. On real hardware, also mention that a read-modify-write on a shared register can race with an ISR, which is why many microcontrollers offer separate set/reset registers.
6. How do you count the set bits in a number, or check for a power of two?
n & (n - 1) clears the lowest set bit. Loop on it and count the passes to get the number of set bits; if one pass gives zero (and n was not zero), n is a power of two.
unsigned count_bits(uint32_t n) { unsigned c = 0; while (n) { n &= n - 1u; c++; } return c; }
bool is_pow2(uint32_t n) { return n != 0u && (n & (n - 1u)) == 0u; }
/* count_bits(0xF0)=4, count_bits(0xFFFFFFFF)=32
is_pow2(64)=1, is_pow2(96)=0, is_pow2(0)=0 */
Follow-up: "What is the cost?" The loop runs once per set bit, not once per bit position, so 0xF0 takes 4 passes. Many compilers also offer a built-in (__builtin_popcount in GCC and Clang) that may map to a single instruction.
7. What is structure padding, and how do you reduce it?
The compiler inserts unused bytes so each member sits at an address that suits its alignment, usually its own size. Ordering members from largest to smallest removes most padding.
struct bad { char a; int b; char c; }; /* size 12: a@0, b@4, c@8 */
struct good { int b; char a; char c; }; /* size 8: b@0, a@4, c@5 */
struct __attribute__((packed)) packed { char a; int b; char c; }; /* size 6 */
These sizes were printed with sizeof and offsetof on a host with 4-byte ints aligned to 4 bytes, which is also typical of 32-bit Arm. They are implementation-defined, and packed is a GCC/Clang extension, not standard C.
Follow-up: "Why not pack every struct?" Packed members can be misaligned, so the compiler must use slower byte-by-byte access, and on some cores an unaligned access through a pointer faults. Pack only structs that must match a wire format or a register layout, and prefer explicit serialisation for protocols.
8. What is endianness, and how do you check it in C?
Endianness is the byte order of a multi-byte value in memory. Little-endian stores the least significant byte at the lowest address; big-endian stores the most significant byte first. Look at the first byte of a known value through an unsigned char pointer.
uint32_t v = 0x12345678u;
const uint8_t *b = (const uint8_t *)&v;
printf("%s-endian, first byte = 0x%02X\n", b[0] == 0x78 ? "little" : "big", b[0]);
/* Output on our host: little-endian, first byte = 0x78
swap32(0x12345678) = 0x78563412 using shifts and masks */
Most Arm Cortex-M parts run little-endian. Network protocols traditionally send multi-byte fields big-endian ("network byte order"), so conversions come up constantly.
Follow-up: "Write a byte swap without a library call." Mask each byte and shift it to its mirror position: ((x & 0xFF) << 24) | ((x & 0xFF00) << 8) | ((x >> 8) & 0xFF00) | (x >> 24) for an unsigned 32-bit x.
9. What are function pointers used for in embedded code?
A function pointer holds the address of a function, so you can choose at run time which code to call. Embedded uses include the interrupt vector table, callbacks from drivers, and table-driven state machines.
typedef enum { ST_IDLE, ST_RUN, ST_FAULT, ST_COUNT } state_t;
typedef state_t (*handler_t)(int input);
static state_t on_idle(int in) { return in > 0 ? ST_RUN : ST_IDLE; }
static state_t on_run(int in) { return in < 0 ? ST_FAULT : ST_RUN; }
static state_t on_fault(int in) { (void)in; return ST_IDLE; }
static const handler_t table[ST_COUNT] = { on_idle, on_run, on_fault };
/* inputs 0, 1, 1, -1, 0 give: IDLE RUN RUN FAULT IDLE */
s = table[s](input);
Follow-up: "Why make the table const?" So it is placed in flash, not RAM, and cannot be overwritten by a stray pointer. Calling through a corrupted function pointer is a classic cause of hard-to-trace crashes.
10. What are the rules for writing an ISR?
Keep it short: clear the interrupt flag, move data into a buffer or set a flag, and leave the heavy work to the main loop or a task. An ISR takes no arguments, returns nothing, and must never block.
- No
printf,mallocor other slow or non-reentrant library calls. - No waiting on a mutex or a delay. In an RTOS, use the ISR-safe API (in FreeRTOS, the functions ending in
FromISR). - Variables shared with the main code are
volatile, and multi-byte shared data is read with interrupts briefly disabled. - Avoid floating point in ISRs unless you know the context-save cost on your core.
Follow-up: "What happens if you forget to clear the interrupt flag?" On many microcontrollers the interrupt fires again as soon as the ISR returns, so the CPU spends all its time in the ISR and the main loop appears frozen.
11. What do these print? (two classic trick questions)
Interviewers like short programs whose output surprises people. Both answers below follow from the C standard, not from the compiler.
unsigned int a = 6;
int b = -20;
puts((a + b > 6) ? "> 6" : "<= 6");
#define SQUARE(x) x * x
#define SQUARE_OK(x) ((x) * (x))
printf("%d %d\n", SQUARE(2 + 3), SQUARE_OK(2 + 3));
/* Output:
> 6
11 25 */
In the first, b is converted to unsigned before the addition, so -20 becomes a huge positive number and the sum is far above 6. In the second, the macro expands to 2 + 3 * 2 + 3, which is 11. Fully parenthesise macro arguments, or use a static inline function.
Follow-up: "What about SQUARE_OK(i++)?" It modifies i twice with no sequence point, which is undefined behaviour. That is the real argument for inline functions over function-like macros.
Microcontroller interview questions
12. What is the difference between a microcontroller and a microprocessor?
A microcontroller puts the CPU, flash, RAM and peripherals (timers, ADC, UART, GPIO) on one chip and is built for a dedicated control task. A microprocessor is mainly a CPU that needs external memory and peripheral chips, and usually runs a full operating system.
An STM32 or an AVR ATmega328 is a microcontroller; the application processor in a phone or a Raspberry Pi is a microprocessor (in a system-on-chip). The trade-off is cost, power and real-time behaviour versus raw performance and an MMU for Linux.
Follow-up: "Harvard or von Neumann?" Harvard has separate buses for instructions and data, so it can fetch both at once; von Neumann shares one. Many modern MCUs use a modified Harvard design internally with one unified memory map.
13. Polling or interrupts? And what is interrupt latency?
Polling means the CPU keeps checking a flag; an interrupt lets the hardware signal the CPU when the event happens. Interrupt latency is the time from the hardware event to the first instruction of its ISR.
Polling is simple and fine for fast, frequent or non-urgent events; interrupts save power and CPU time for rare or urgent ones. Latency grows with: code that runs with interrupts disabled, a higher-priority ISR already running, finishing the current instruction, saving the context, and flash wait states. On Arm Cortex-M the interrupt controller (NVIC) saves eight registers in hardware, which is why an ISR there can be an ordinary C function.
Follow-up: "How would you measure it?" Toggle a GPIO pin at the start of the ISR and compare it with the triggering signal on an oscilloscope or logic analyser. Measure the worst case under load, not the average.
14. How do you configure a timer for a 1 ms tick or a PWM output?
Divide the timer clock with a prescaler, then set the auto-reload value so the counter overflows at the rate you want. On STM32-style timers, the output frequency is and the PWM duty cycle is .
Worked example (checked by a C program)
- 1 ms tick from 16 MHz: PSC = 15 gives a 1 MHz counter clock; ARR = 999 gives Hz.
- 20 kHz PWM at 25% duty from 72 MHz, no prescaler: ; .
Follow-up: "What limits PWM resolution?" ARR + 1 is the number of duty steps: 3,600 steps at 20 kHz from 72 MHz. Doubling the PWM frequency halves the steps. Motor drives above about 20 kHz are popular because the switching noise moves above the range people hear.
15. What is a watchdog timer, and where should you kick it?
A watchdog is a hardware timer that resets the microcontroller if the software fails to refresh ("kick") it within a set time. It recovers a system that has hung in a loop, deadlocked or lost its way after memory corruption.
Kick it from one place in the main loop, and only after checking that every important task has made progress in that cycle. Kicking it from a timer interrupt is the classic mistake: the timer keeps firing even while the main code is stuck, so the watchdog never resets anything.
Follow-up: "What is a window watchdog?" One that also resets the chip if it is kicked too early. It catches code that runs away in a tight loop and kicks too often, not only code that stops.
16. What is ADC resolution, and how do you convert a reading to volts?
An N-bit ADC splits its reference voltage into steps. The voltage is , so a 12-bit ADC at 3.3 V has a step (LSB) of 0.806 mV and a reading of 2048 means 1.650 V.
A 10-bit ADC at the same reference has a 3.22 mV step. Some datasheets divide by instead; the difference is one LSB at full scale, but say which convention you use. Resolution is not accuracy: offset, gain error, noise and reference drift often cost more than one LSB.
Follow-up: "What sampling rate do you need?" At least twice the highest frequency in the signal (the Nyquist criterion), in practice more, with an analogue low-pass (anti-aliasing) filter before the ADC so higher frequencies cannot fold back into the band.
17. Where do variables live in a microcontroller's memory?
Code and constants live in flash (.text and .rodata). Initialised globals and statics live in RAM in .data, with their start values stored in flash. Zero-initialised ones live in .bss. Locals live on the stack, and malloc memory on the heap.
| Declaration | Section | Memory |
|---|---|---|
const int table[4] = {1,2,3,4}; (global) | .rodata | Flash |
int count = 5; (global) | .data | RAM, start value copied from flash |
static int total; | .bss | RAM, zeroed at startup |
int x; inside a function | Stack | RAM |
Follow-up: "Why do many embedded coding standards discourage malloc?" Heap use can fragment a small RAM over hours of running, and allocation time is not predictable. Static allocation lets you prove at build time that memory fits.
18. What happens between reset and main()? What does a bootloader do?
The startup code prepares the C run-time before main() runs. On an Arm Cortex-M, the core loads the initial stack pointer from the first word of the vector table and jumps to the reset handler in the second word, which copies .data from flash to RAM, zeroes .bss, sets up clocks and then calls main().
A bootloader is a small program that runs first and decides what to start: it can check the application image (for example with a CRC), receive a new image over UART, CAN or USB, write it to flash, and then jump to the application's vector table.
Follow-up: "What happens if .bss is not zeroed?" Globals that the code assumes start at zero hold whatever was in RAM, so the program behaves differently after a power cycle than after a reset. It is a good answer to "why does it only fail sometimes?".
Communication protocol questions: UART, I2C, SPI and CAN
19. How do UART, I2C, SPI and CAN compare?
UART is a two-wire, point-to-point link with no clock. I2C is a two-wire addressed bus for slow on-board chips. SPI is a fast four-wire bus with one chip-select line per device. CAN is a two-wire differential bus built for noisy vehicles and factories, with priorities and strong error detection.
| UART | I2C | SPI | CAN (classical) | |
|---|---|---|---|---|
| Wires | TX, RX (+ ground) | SDA, SCL | SCLK, MOSI, MISO, CS per device | CAN_H, CAN_L (twisted pair) |
| Clock | None (both sides agree a baud rate) | Shared, from the controller | Shared, from the controller | None (nodes resynchronise on edges) |
| Duplex | Full | Half | Full | Half |
| Devices | 2 | Many, by 7-bit or 10-bit address | Many, one CS each | Many, by message identifier |
| Typical speed | 9,600 to 115,200 baud common | 100 kbit/s, 400 kbit/s, 1 Mbit/s, 3.4 Mbit/s modes | Several MHz, set by the devices | Up to 1 Mbit/s |
| Acknowledge | None | ACK bit after every byte | None | ACK slot in every frame |
| Typical use | Debug console, GPS, Bluetooth modules | Sensors, EEPROM, RTC | Flash, displays, fast ADCs | ECUs in vehicles, industrial nodes |
I2C speeds are from the NXP I2C specification (UM10204 Rev. 7.0); the CAN rate is from TI's CAN application note (SLOA101B). SPI has no single formal standard, so its speed depends on the parts you connect.
Follow-up: "Which would you pick to connect five sensors on one board?" Usually I2C, because it needs only two wires for all five. Pick SPI if one of them needs high throughput, and CAN if the sensors are in separate modules metres apart in a noisy environment.
20. What does a UART frame look like, and why does baud-rate error matter?
Each UART character is a start bit (low), 5 to 9 data bits sent least significant bit first, an optional parity bit and 1 or 2 stop bits (high). In the common 8N1 format a byte costs 10 bits, so 9,600 baud moves 960 bytes per second and 115,200 baud moves 11,520.
Because there is no clock wire, both sides must run close to the same baud rate. A worked case from our C check: a 16 MHz clock with 16x oversampling needs a divisor of 8.68 for 115,200 baud. Rounding to 9 gives 111,111 baud, an error of -3.55%, enough to corrupt characters. That is why UARTs have fractional dividers, and why 14.7456 MHz crystals exist: they divide to exactly 8.000.
Follow-up: "Is baud rate the same as bit rate?" For a simple UART, yes: one symbol carries one bit. The useful data rate is lower because the start, stop and parity bits carry no data.
21. How do I2C ACK and NACK work, and why does I2C need pull-up resistors?
After every byte, the transmitter releases SDA and the receiver pulls it low during the ninth clock pulse to acknowledge (ACK). If SDA stays high during that ninth pulse, it is a not-acknowledge (NACK). The controller then sends a STOP or a repeated START.
The NXP specification lists five causes of a NACK: no device has that address; the device is busy; it received data or a command it does not understand; it cannot accept more bytes; or a controller reading data uses NACK to mark the last byte it wants. I2C lines are open-drain, meaning devices can only pull them low, so pull-up resistors bring them high. That wired-AND behaviour is also what makes clock stretching and multi-controller arbitration possible.
Follow-up: "A device has 7-bit address 0x50. What is the first byte on the bus?" The address shifted left by one, plus the R/W bit: 0xA0 to write, 0xA1 to read. Mixing up 7-bit and 8-bit address notation is the most common reason a new I2C driver gets only NACKs.
22. What are the four SPI modes?
The mode is set by two bits. CPOL is the clock level when idle (0 = low, 1 = high), and CPHA says whether data is sampled on the first (0) or second (1) clock edge. Controller and device must use the same mode.
| Mode | CPOL | CPHA | Clock idles | Data sampled on |
|---|---|---|---|---|
| 0 | 0 | 0 | Low | Rising edge |
| 1 | 0 | 1 | Low | Falling edge |
| 2 | 1 | 0 | High | Falling edge |
| 3 | 1 | 1 | High | Rising edge |
Follow-up: "SPI has no ACK. How do you know the device is there?" Read back a known register, such as a WHO_AM_I or device-ID register, at start-up and compare it with the datasheet value.
23. How does CAN arbitration work?
Every node sends its identifier bit by bit while reading the bus back. A 0 (dominant) overrides a 1 (recessive), so a node that sends a 1 but reads a 0 knows a higher-priority message is on the bus and stops. The lowest identifier wins, and its frame is never corrupted.
const uint16_t id[3] = { 0x123, 0x125, 0x1A0 };
int active[3] = { 1, 1, 1 };
for (int bit = 10; bit >= 0; bit--) { /* MSB first */
int bus = 1; /* recessive unless someone drives 0 */
for (int n = 0; n < 3; n++)
if (active[n] && !((id[n] >> bit) & 1)) bus = 0;
for (int n = 0; n < 3; n++)
if (active[n] && ((id[n] >> bit) & 1) && bus == 0) {
active[n] = 0;
printf("0x%03X loses at ID bit %d (sent recessive 1, read dominant 0)\n", id[n], bit);
}
}
/* Output:
0x1A0 loses at ID bit 7 (sent recessive 1, read dominant 0)
0x125 loses at ID bit 2 (sent recessive 1, read dominant 0)
0x123 wins and keeps transmitting */
This is why CAN is called non-destructive: no time is lost to collisions, and the most urgent message (lowest ID) always goes first. The losers retry automatically when the bus is idle.
Follow-up: "What if two nodes send the same identifier?" They must not; each identifier should have only one sender. If the data differ, the nodes detect a bit error in the data field and raise error frames. Also expect "why must a CAN bus have 120 Ω at each end?" The terminations match the cable's characteristic impedance to stop reflections, and they pull the bus back to recessive.
24. What is in a CAN frame, and what does CAN FD change?
A classical CAN data frame has: start of frame, an 11-bit (standard) or 29-bit (extended) identifier, RTR and IDE bits, a 4-bit data length code, 0 to 8 data bytes, a 15-bit CRC plus delimiter, a 2-bit ACK field and a 7-bit end of frame. After five equal bits in a row, the sender inserts an opposite "stuff" bit so receivers stay in sync.
CAN FD (flexible data rate) raises the payload to 64 bytes and, when the BRS (bit rate switch) bit is set, sends the data phase at a higher bit rate than the arbitration phase. Arbitration still runs at up to 1 Mbit/s because every node must see every bit within one bit time. ISO 11898-2:2016 specified transceivers for data phases of 2 and 5 Mbit/s. Classical CAN and CAN FD are now specified together in ISO 11898-1:2024.
Follow-up: "What is the dominant bit in the ACK slot for?" Every receiver that got the frame without error drives the ACK slot dominant. A sender that sees it stay recessive knows nobody received the frame correctly and treats it as an error. For how a signal gets from application code into a CAN frame in a car, see our AUTOSAR interview questions.
RTOS interview questions
25. What states can an RTOS task be in?
In FreeRTOS a task is Running (using the CPU), Ready (able to run but a task of equal or higher priority is running), Blocked (waiting for a time delay, queue, semaphore or event) or Suspended (taken out of scheduling until resumed). A deleted task whose memory is not yet freed is reported as Deleted.
Only one task per core is Running. The scheduler always runs the highest-priority Ready task; tasks of equal priority can share time by round-robin time slicing if it is enabled.
Follow-up: "What is the difference between Blocked and Suspended?" Blocked waits for an event and can have a timeout. Suspended waits for nothing: only an explicit resume call brings it back.
26. What is the difference between a mutex and a semaphore?
A mutex guards a shared resource: the task that takes it must give it back, and in FreeRTOS it includes priority inheritance. A binary or counting semaphore signals events or counts resources: one task or ISR gives it and another takes it, and there is no owner.
So use a mutex around a shared SPI bus or a UART. Use a binary semaphore when an ISR needs to wake a task ("data is ready"), and a counting semaphore for a pool of N identical buffers. FreeRTOS's documentation states that mutexes cannot be used from inside an ISR, while its binary semaphores can be given from one.
Follow-up: "What is a recursive mutex?" One the same task can take several times without deadlocking itself; it must give it back the same number of times before another task can take it.
27. What is priority inversion, and how does priority inheritance fix it?
Priority inversion is when a high-priority task waits for a low-priority task that holds a shared resource, and a medium-priority task pre-empts the low one. The high task ends up waiting for the medium one. Priority inheritance lifts the low task to the high task's priority while it holds the lock, so the medium task cannot get in the way.
The famous case is NASA's Mars Pathfinder in 1997. A high-priority bus management task waited on a mutex held by a low-priority meteorological task, while a medium-priority communications task kept running. The stalled bus task was detected and the spacecraft reset itself repeatedly. Engineers reproduced it on a replica, found that the VxWorks mutex had priority inheritance turned off, and uploaded a patch that turned it on.
Follow-up: "Name another fix." The priority ceiling protocol raises a task to a preset ceiling priority (the highest of any task that uses the resource) as soon as it takes the lock. Keeping critical sections short helps in every case.
28. What is a deadlock, and how do you prevent it?
A deadlock is when two or more tasks each hold a resource the other needs, so none can continue. Task A holds the SPI mutex and waits for the UART mutex, while task B holds the UART mutex and waits for SPI.
It needs four conditions at once: mutual exclusion, hold and wait, no pre-emption of resources, and a circular wait. Break any one and deadlock cannot happen. The practical rule is to always take locks in the same global order; add timeouts on lock calls so a stuck task can report an error instead of hanging silently.
Follow-up: "Deadlock vs livelock vs starvation?" In a deadlock nothing moves. In a livelock tasks keep running but make no progress, for example backing off and retrying in step. In starvation one task never gets the CPU or the resource because others always win.
Debugging interview questions
29. Your firmware crashes on the board. How do you debug it?
Connect a hardware debugger over SWD or JTAG, halt on the fault, and read where the code was when it failed. On a Cortex-M, the fault handler's stacked registers give the program counter of the faulting instruction, and the fault status registers say why (bad memory access, unaligned access, divide by zero if enabled, or an invalid instruction).
Microcontrollers without an MMU usually do not give a "segmentation fault" like a PC does. A bad pointer either triggers a hard fault or silently corrupts memory, which is worse. The usual suspects are stack overflow, an uninitialised or dangling pointer, a buffer overrun, and data shared with an ISR without protection.
- Stack overflow: fill the stack with a known pattern and check how much was overwritten; in FreeRTOS, set
configCHECK_FOR_STACK_OVERFLOWand implementvApplicationStackOverflowHook. - Timing bugs: GPIO toggles and a logic analyser;
printfover UART changes the timing it is trying to measure. - Bus problems: a logic analyser or oscilloscope on SDA/SCL, SPI or CAN lines to see the actual bytes, ACKs and voltage levels.
Follow-up: "Why does it work with the debugger attached but not without?" Common causes are timing changes, a variable missing volatile (debug builds often turn optimisation off), uninitialised memory that happens to be zero in one case, or a clock or power-up sequence that differs.
Automotive embedded questions
30. What are the layers of AUTOSAR Classic?
AUTOSAR Classic has three top-level layers: the Application layer of software components, the Runtime Environment (RTE) that connects them, and the Basic Software (BSW). The BSW is split into the Services layer, the ECU Abstraction layer, the Microcontroller Abstraction Layer (MCAL) and Complex Drivers.
The point is portability: application components talk only to the RTE, so they can move between ECUs and microcontrollers, while the MCAL holds the chip-specific drivers (ADC, CAN, SPI, PWM, DIO and so on). This is from AUTOSAR's Layered Software Architecture document, release R25-11.
Follow-up: "When would you write a Complex Driver?" For hardware AUTOSAR does not standardise, or for timing too tight for the layered stack. Our 28-question AUTOSAR guide covers the RTE, the COM stack and diagnostics in depth.
31. What is MISRA C, and why do automotive companies use it?
MISRA C is a set of coding guidelines that restricts C to a safer subset for critical systems. It bans or limits constructs whose behaviour is undefined, unspecified or easy to misread, so code is more predictable and can be checked by static analysis tools.
It started in the motor industry and is now also used in rail, aerospace, defence and medical devices. The current edition is MISRA C:2025, published in March 2025; it follows MISRA C:2023 (April 2023) and MISRA C:2012, which many existing projects still follow. Several earlier answers here are MISRA topics: implicit signed/unsigned conversion and function-like macros (question 11), and dynamic memory (question 17).
Follow-up: "What if your code must break a rule?" MISRA allows a documented deviation: you record the rule, the reason and why it is safe, and get it approved. Silent violations are what auditors object to.
What salary does an embedded engineer fresher get in India?
In Skill-Lync's placement records, learners placed as Embedded Engineers in the embedded domain had a median starting salary of ₹4.0 LPA, with the middle half between ₹3.5 and ₹5.0 LPA (n = 138, snapshot 15 Nov 2026). Across all embedded-domain roles the median was also ₹4.0 LPA (n = 278). Live figures are on the embedded engineer salary page.
| Group (Skill-Lync placements) | n | Median | 25th to 75th percentile | 90th percentile |
|---|---|---|---|---|
| Embedded domain, Embedded Engineer | 138 | ₹4.0 LPA | ₹3.5 to 5.0 LPA | ₹6.0 LPA |
| Embedded domain, Graduate Engineer Trainee | 95 | ₹4.0 LPA | ₹3.5 to 4.8 LPA | ₹5.0 LPA |
| All embedded-domain roles | 278 | ₹4.0 LPA | ₹3.5 to 5.0 LPA | ₹5.8 LPA |
| Embedded domain, 2022 placements | 133 | ₹4.5 LPA | ₹3.5 to 5.0 LPA | ₹5.9 LPA |
| Embedded domain, 2023 placements | 98 | ₹4.0 LPA | ₹3.3 to 4.7 LPA | ₹5.5 LPA |
| Embedded domain, 2024 placements | 42 | ₹3.2 LPA | ₹3.0 to 4.0 LPA | ₹5.7 LPA |
Snapshot: 15 Nov 2026, records up to 7 Nov 2026. Read these figures with three caveats. They come from Skill-Lync learners who reported a placement, not the whole job market. They are mostly starting offers. And almost all embedded records are from 2022 to 2024: no later year has 10 or more records, so the 2024 dip rests on 42 people and is not a trend you can rely on.
How should you prepare for an embedded interview?
- Type and run the snippets. Change one line at a time and predict the output before you run it. Interviewers often ask you to write bit-manipulation code on paper.
- Bring one hardware project you can defend: which microcontroller, which peripherals, the clock and timer settings, one bug you chased and how you found it. A logic-analyser capture of your own I2C or UART traffic is a strong talking point.
- Know one RTOS by name. FreeRTOS is free and well documented; be ready to explain the task states and when you would use a queue, a semaphore or a mutex.
- For automotive roles, add CAN and basic AUTOSAR. Project ideas are on our electrical and embedded project ideas page.
If you want structured practice, Skill-Lync's PG Program in Embedded Systems for EV Applications (24 weeks; C, STM32CubeIDE, AVR ATmega328, Arm Cortex-M4, CAN, Embedded Linux) and the shorter Embedded Programming Essentials course cover most of the C and microcontroller questions above with project work. All embedded courses are on the embedded systems courses page.
Frequently asked questions
What questions are asked in an embedded systems interview for freshers?
Expect Embedded C (volatile, const, static, pointers, bit manipulation, structure padding), microcontroller basics (interrupts, timers, ADC, PWM, watchdog, startup code), serial protocols (UART, I2C, SPI, CAN) and RTOS concepts (task states, mutex versus semaphore, priority inversion), plus questions on your own project.
Is Embedded C different from C?
Embedded C is standard C used on microcontrollers, plus compiler extensions for things like interrupt handlers and memory placement. The language is the same; the habits differ: fixed-width types such as uint8_t, volatile for hardware registers, little or no dynamic memory, and close attention to timing and RAM use.
Which microcontroller should I learn for embedded interviews?
An Arm Cortex-M board such as an STM32 is the most useful single choice for industry roles, because Cortex-M parts are common in automotive and industrial products. An 8-bit AVR (the ATmega328P on an Arduino Uno) is a good first step for learning registers without too much complexity.
Do I need to know an RTOS as a fresher?
You need the concepts more than a specific product: tasks and their states, scheduling by priority, queues, semaphores, mutexes, priority inversion and deadlock. Being able to say you built a small FreeRTOS project with two or three tasks makes those answers concrete.
What is the starting salary for an embedded engineer in India?
In Skill-Lync's placement records, the median starting salary for Embedded Engineers was ₹4.0 LPA, with the middle half between ₹3.5 and ₹5.0 LPA (n = 138, snapshot 15 Nov 2026). Most records are 2022 to 2024 offers, so treat them as a guide.
Sources and further reading
- Skill-Lync placement records, Skill-Lync, aggregate snapshot of 15 Nov 2026 (3,711 records up to 7 Nov 2026).
- UM10204, I2C-bus specification and user manual, Rev. 7.0, NXP Semiconductors, 1 Oct 2021, read 16 Nov 2026.
- Introduction to the Controller Area Network (CAN), SLOA101B, Texas Instruments, revised May 2016, read 16 Nov 2026.
- Controller Area Network classic (CAN CC) and CAN FD: the basic idea, CAN in Automation, read 16 Nov 2026.
- TJA1441 CAN FD transceiver data sheet (ISO 11898-2:2016, data phase up to 5 Mbit/s), NXP Semiconductors, read 16 Nov 2026.
- SPI data modes, Microchip 8-bit AVR documentation, read 16 Nov 2026.
- FreeRTOS kernel source (task.h task states, semphr.h mutex and semaphore notes), FreeRTOS, read 16 Nov 2026.
- What really happened on Mars?, Mike Jones, 7 Dec 1997, read 16 Nov 2026.
- Layered Software Architecture, Classic Platform R25-11, AUTOSAR, 27 Nov 2025, read 15 Nov 2026.
- MISRA C, MISRA, read 16 Nov 2026.
- Tata Elxsi recruitment process and KPIT interview process, FACE Prep, May 2026, read 16 Nov 2026.
