Embedded Systems & Firmware

Learn the basics of embedded systems and firmware with multiple-choice questions: register access and bit manipulation, GPIO and timers, interrupt-handler pitfalls, UART, SPI and I2C, RTOSes and watchdogs.

—Your accuracy
0 / 50Questions answered
Practice this topicAll questions in this topic, in random order Weak questionsRetry only the questions you last got wrong

Embedded Systems & Firmware: key points

Inside appliances, cars and industrial equipment, firmware running on microcontrollers controls the device. Firmware reads and writes peripheral registers directly, using bit manipulation to change specific bits, to drive pin I/O (GPIO), timers and communication peripherals.

Embedded code has its own rules, such as keeping interrupt handlers short and declaring shared variables volatile. From UART, SPI and I2C communication and RTOSes that switch tasks by priority to the boot loader that runs first at power-on and the watchdog that recovers from runaway code, this topic covers the software closest to the hardware.

All Embedded Systems & Firmware questions (50)

  1. In C, which statement sets only bit 3 of register reg to 1 without changing the other bits?
  2. In C, which statement clears only bit 3 of register reg to 0 without changing the other bits?
  3. To toggle an LED output pin bit between on and off each time the code runs, which C statement is correct?
  4. Which C condition correctly tests whether bit 5 of input register in is 1?
  5. The code above rewrites a multi-bit field of register reg. What does it do?
  6. While the main code updates a register bit with "reg |= mask;" (read-modify-write), an interrupt handler changes a different bit of the same register. Which pairs the possible problem with a fix correctly?
  7. A switch alone is connected to a microcontroller input pin, with no pull-up or pull-down resistor. What can happen while the switch is open?
  8. When using a microcontroller GPIO (general-purpose input/output) pin, what must be configured first?
  9. What is the phenomenon called in which a mechanical switch's contacts bounce, turning on and off many times in a short period when pressed?
  10. Which is the most suitable way to remove switch bounce in software?
  11. A timer counts a 16 MHz clock divided by 16 with a prescaler and raises an interrupt every 1000 counts. What is the interrupt interval?
  12. A PWM signal has a period of 1000 counts, with the output high (1) for 250 counts of each period. What is the duty cycle?
  13. Which method is commonly used by microcontrollers to adjust LED brightness or motor speed?
  14. What is the input capture function of a microcontroller timer used for?
  15. What should be avoided inside an interrupt handler?
  16. When the program above is compiled with optimization, led_on() may never be called even after the timer interrupt fires. Which pairs the cause with the fix correctly?
  17. On an 8-bit microcontroller, a timer interrupt increments the 32-bit variable ticks, and the main code reads ticks to compute elapsed time. Why is a wildly wrong value occasionally read?
  18. What is a characteristic of serial communication with a UART?
  19. On a 115200 bps UART using 8 data bits, no parity and 1 stop bit (8N1), roughly how many bytes can be sent per second?
  20. A small baud-rate mismatch between UART transmitter and receiver can garble characters. Why is the tolerance limited to roughly a few percent?
  21. What is a characteristic of SPI communication?
  22. Which set of four signals is generally used by SPI?
  23. When an SPI part is connected but correct data cannot be read, which setting is most worth checking?
  24. What is a characteristic of I2C communication?
  25. In I2C, how does the receiver of a data byte acknowledge it?
  26. You want to connect two identical I2C temperature sensors to the same I2C bus, but both have the same address. Which is a correct solution?
  27. Which comparison of UART, SPI and I2C is correct?
  28. What is the difference between polling and interrupts as ways to learn a peripheral's status?
  29. Which describes the "super loop" structure often seen in microcontroller programs without an OS?
  30. What is the main purpose of using an RTOS (real-time operating system) in embedded devices?
  31. In a preemptive RTOS, while a low-priority task is running, a high-priority task receives the data it was waiting for and becomes ready. What generally happens?
  32. Which describes priority inversion in an RTOS?
  33. Which describes priority inheritance, used to prevent priority inversion?
  34. In an RTOS, what is the advantage of using a queue (message queue) to pass data from a sensor-reading task to a display task?
  35. What is the difference between hard real-time and soft real-time?
  36. Why is it bad practice to kick (reset) the watchdog timer unconditionally inside a 1 ms timer interrupt handler?
  37. What is the role of a bootloader in an embedded device?
  38. In devices updated over the air (OTA), why is flash divided into two firmware slots (A and B)?
  39. What is the main purpose of using a microcontroller's sleep mode in a battery-powered embedded device?
  40. A sensor device runs at 10 mA for 1% of the time and sleeps at 10 µA for the remaining 99%. What is the closest average current?
  41. Why does firmware on small microcontrollers often avoid dynamic memory allocation such as malloc?
  42. On a small microcontroller without an MMU, what should be kept in mind about excessive stack use?
  43. A 12-bit A/D converter with a 3.3 V reference reads a value of 2048. What is the closest input voltage?
  44. When a microcontroller captures many A/D conversion results at regular intervals, what is the advantage of using DMA?
  45. When representing peripheral registers with C bit-field structs, what needs care?
  46. On many microcontrollers, what is the advantage of declaring a large table that never changes (such as font data) as const?
  47. What can be done through debug interfaces such as JTAG and SWD?
  48. You want to run a control calculation every 1 ms on a microcontroller without an OS. Which implementation is most suitable?
  49. What is the role of a microcontroller's brown-out detector (BOD, brown-out reset)?
  50. On a microcontroller with interrupt priorities, a higher-priority interrupt occurs while a lower-priority handler is running. What generally happens (assuming nesting is allowed)?

Other topics in Computer systems