Interview Prep & Tips /Embedded Systems

Embedded C essentials

BeginnerEmbedded C

Sample guide. Edit or replace it with your own material.

1. What does volatile do, and when do you need it?

2. Where do variables live?

Section Contents Location at runtime
.text Code and constants (often .rodata too) Flash
.data Initialised globals and statics RAM, with initial values copied from flash at startup
.bss Zero-initialised or uninitialised globals and statics RAM, zeroed at startup
Stack Local variables, return addresses RAM
Heap malloc allocations (often avoided in embedded) RAM

3. The meanings of static

4. Rules for writing ISRs

5. Integer promotion trap

uint8_t a = 0xFF;
if (~a == 0x00) {
    /* Never reached */
}

a is promoted to int before ~ is applied, so ~a is 0xFFFFFF00 (on a 32-bit int), not 0x00. The fix is (uint8_t)~a == 0x00.

Practice

Want a mock interview on this?

Practise for 30 minutes with feedback from someone who works in the field.

Book a Mock Interview