Embedded Systems Engineer
Embedded C questions
183 questions on Embedded C for embedded systems engineers, easiest first.
Easy 55
- Why use volatileeasy
- Setting a register biteasy
- Dynamic memory on small MCUseasy
- Reading a hex register valueeasy
- Adding to a uint8_t countereasy
- Where const goes in a pointereasy
- What lives in .bsseasy
- A static local countereasy
- Why a cross-compilereasy
- Keeping a table out of RAMeasy
- First byte in memoryeasy
- Integer division resultseasy
- A macro without parentheseseasy
- Incrementing a uint32_t pointereasy
- Passing an array to a functioneasy
- Returning a local buffereasy
- A register access macroeasy
- Toggling an LED biteasy
- sizeof a pointer and an arrayeasy
- Subtracting two pointerseasy
- Accessing a member through a pointereasy
- Writing through an unset pointereasy
- A read-only buffer parametereasy
- A designated array initialisereasy
- Zeroing a local structeasy
- Why swap needs pointerseasy
- Where .data starts outeasy
- Which way the stack growseasy
- static on a global variableeasy
- Sharing a global between fileseasy
- A big buffer inside a functioneasy
- Recursion in firmwareeasy
- Default value of a static localeasy
- Default value of a localeasy
- Why include guardseasy
- An undefined reference erroreasy
- The register keyword todayeasy
- Shrinking a struct by reorderingeasy
- Choosing -Os for flasheasy
- What goes in .rodataeasy
- ELF file or BIN fileeasy
- Why use uint32_t over unsigned longeasy
- Storing -1 in a uint8_teasy
- Storing 0x1234 in a byteeasy
- Converting a float to inteasy
- A float comparison that failseasy
- A leading zero in a numbereasy
- Adding one to UINT32_MAXeasy
- Heavy work in an interrupteasy
- printf in an interrupteasy
- What MISRA C is foreasy
- A missing breakeasy
- Guarding a pointer in one testeasy
- Value of an uninitialised globaleasy
- Where initialised globals come fromeasy
Medium 74
- Size of a structmedium
- Adding two uint8_t valuesmedium
- Comparing int with unsignedmedium
- Bit-fields for hardware registersmedium
- sizeof on an array parametermedium
- C++ features often disabledmedium
- Choosing task stack sizesmedium
- Ring buffer index with a maskmedium
- What filled the flashmedium
- Dropping unused functionsmedium
- Initialised global reads garbagemedium
- Stuck in Default_Handlermedium
- Multiplying Q15 numbersmedium
- Declaring a function pointermedium
- A command dispatch tablemedium
- Callbacks with a context pointermedium
- Arithmetic on void pointersmedium
- Extracting a register fieldmedium
- Writing a register fieldmedium
- Returning a pointer through a parametermedium
- const and volatile togethermedium
- A variable changes by itselfmedium
- Changing a string literalmedium
- strncpy and the missing terminatormedium
- Shifting bytes inside a buffermedium
- Row-major layout of a 2D arraymedium
- What offsetof givesmedium
- A linked list without mallocmedium
- State machine with function pointersmedium
- Pointer size on an 8-bit AVRmedium
- A NULL check after usemedium
- A struct over peripheral registersmedium
- What *p++ doesmedium
- Calling an unset callbackmedium
- Building a value from bytesmedium
- Heap and stack meetingmedium
- Same global in two filesmedium
- The MEMORY block of a linker scriptmedium
- Putting a buffer in a special RAMmedium
- The first two vector table wordsmedium
- What runs before mainmedium
- Weak handlers in startup filesmedium
- Per-function stack figuresmedium
- const tables still in RAM on AVRmedium
- Is returning a literal safemedium
- Fixed-size block poolmedium
- malloc fails with free memorymedium
- A variable-length arraymedium
- A struct copy inside an ISRmedium
- Small helpers in a headermedium
- How startup finds .datamedium
- Where newlib gets heap memorymedium
- Library order on the link linemedium
- What LTO addsmedium
- Reading bytes of a value via a unionmedium
- char on ARM and x86medium
- Shifting a negative number rightmedium
- A timeout that survives wraparoundmedium
- Raw ADC count to millivoltsmedium
- Rounding an integer divisionmedium
- Remainder of a negative numbermedium
- i = i++ and similarmedium
- Two reads in one callmedium
- A volatile counter loses countsmedium
- Reading a 64-bit tick on a 32-bit MCUmedium
- A formatter used by main and an ISRmedium
- A MAX macro with side effectsmedium
- Why do { } while (0)medium
- A config flag set to 0medium
- Checking a struct size at build timemedium
- Widening a negative bytemedium
- Adding without wrappingmedium
- Halted in Default_Handlermedium
- malloc fails after daysmedium
Hard 54
- Corruption in one taskhard
- DMA data looks stalehard
- Reading a 32-bit fieldhard
- Works at -O0, fails at -O2hard
- An overflow check that vanisheshard
- Reading a float from a packethard
- Packed struct crashes a Cortex-M0hard
- Slow maths on a Cortex-M4Fhard
- Proving the stack is big enoughhard
- Inverting a uint8_thard
- Reading NULL does not crashhard
- Lost GPIO updates from an ISRhard
- What restrict promiseshard
- Reading a float as uint32_thard
- An array exactly the string lengthhard
- Detecting snprintf truncationhard
- A flexible array memberhard
- Recovering the parent structhard
- Ordering pointers from different arrayshard
- Writing to a const tablehard
- Aligning a DMA bufferhard
- Reading a string from AVR flashhard
- Pointer to an array of eighthard
- Storing a pointer in an integerhard
- sizeof a member through a null pointerhard
- Reading arm-none-eabi-sizehard
- Keeping a value across a resethard
- App interrupts go to the bootloaderhard
- One table, flash and RAMhard
- printf of a double prints garbagehard
- Erasing flash from flashhard
- Initialising a global with a callhard
- Catching stack overflow at oncehard
- Two stack pointers on Cortex-Mhard
- Vector table vanished from the imagehard
- Bit-band alias addresseshard
- DMA reads zeros from a bufferhard
- A string table that uses RAMhard
- Load address and run addresshard
- An odd function addresshard
- Multiplying two uint16_t valueshard
- Building a bit 31 maskhard
- Shifting by 32hard
- One million on an 8-bit MCUhard
- ADC maths gives wrong millivoltshard
- Atomics on a Cortex-M0hard
- Flag cleared as the last ISR linehard
- Enum size differs between buildshard
- A ready flag that is always falsehard
- abs of the most negative inthard
- Converting 300.0 to a bytehard
- Dividing by zero on Cortex-M3hard
- C++ globals never constructedhard
- Crash only when printing floatshard